#549 PKCS10Client tool throws java exception NoClassDefFoundError
Closed: Fixed Opened by aakkiang.

Trying to create a PKCS#10 certificate request using PKCS10Client tool, throws java exception.

rpm -q pki-tools

pki-tools-10.0.1-3.20130307T0640zgit0a9dc32.fc18.x86_64

PKCS10Client -p Password -d /tmp/tmp.IXGjjHQwaD/nssdb -a rsa -l 1024 -o /tmp/tmp.IXGjjHQwaD/req1.out -n "CN=test.example.com"

PKCS10Client: token NSS Certificate DB logged in...
PKCS10Client: key pair generated.
PKCS10Client: pair.getPublic() called.
PKCS10Client: CertificationRequestInfo() created.
PKCS10Client: CertificationRequest created.
PKCS10Client: certRequest not null.
PKCS10Client: calling BtoA().
Exception in thread "main" java.lang.NoClassDefFoundError: com/netscape/certsrv/apps/CMS
at com.netscape.cmstools.PKCS10Client.main(PKCS10Client.java:291)
Caused by: java.lang.ClassNotFoundException: com.netscape.certsrv.apps.CMS
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more

alee suggested a workaround to add the tool path ( CP=/usr/share/java/${PRODUCT}/pki-certsrv.jar:${CP} ) to /usr/bin/PKCS10Client since jars were re-arranged recently.

cat /usr/bin/PKCS10Client | tail -5

CP=/usr/share/java/${PRODUCT}/pki-certsrv.jar:${CP}
${JAVA} ${JAVA_OPTIONS} -cp ${CP} com.netscape.cmstools.${COMMAND} "$@"
exit $?

PKCS10Client request throws NullPointerException.

[root@hp-dl shared]# PKCS10Client -p Password -d /tmp/tmp.IXGjjHQwaD/nssdb -a rsa -l 1024 -o /tmp/tmp.IXGjjHQwaD/req1.out -n "CN=test.example.com"
PKCS10Client: token NSS Certificate DB logged in...
PKCS10Client: key pair generated.
PKCS10Client: pair.getPublic() called.
PKCS10Client: CertificationRequestInfo() created.
PKCS10Client: CertificationRequest created.
PKCS10Client: certRequest not null.
PKCS10Client: calling BtoA().
PKCS10Client: Exception caught: java.lang.NullPointerException


Recently the CRMFPopClient and PKCS10Client were changed to use CMS.BtoA() or CMS.AtoB(). These methods actually are server-side method because it depends on CMSEngine which doesn't exist on the client side, so the client would fail. They should be replaced with Utils.base64encode() and Utils.base64decode(), respectively.

Fixed and pushed to master in 632aa9a012839bde3253ff7a6698797ba83d4658

Metadata Update from @aakkiang:
- Issue assigned to kaskahn
- Issue set to the milestone: 10.0.2

Dogtag PKI is moving from Pagure issues to GitHub issues. This means that existing or new
issues will be reported and tracked through Dogtag PKI's GitHub Issue tracker.

This issue has been cloned to GitHub and is available here:
https://github.com/dogtagpki/pki/issues/1119

If you want to receive further updates on the issue, please navigate to the
GitHub issue and click on Subscribe button.

Thank you for understanding, and we apologize for any inconvenience.

Metadata