RAD TLS Client in Java

The Java implementation has the Connection.connectTLS(hostname, port, certfiles, locale, keystorefname, keystorepassfname) method. This method enables you to specify a PKCS #12 archive (keystorefname) and the file that holds the password (keystorepassfname) used to unlock the PKCS #12 archive.

The following example test code verifies the functionality of the RAD TLS client X.509 authentication implementation:

Because Java cannot use the default X.509 certificates and their corresponding key file like C and Python can, a Java user must first create a PKCS #12 archive from the certificate and key files. The following example test code fragment shows how to create the archive:

# Create a PKCS#12 keystore that Java can use

pkcs12_password=$(od -An -N6 -x /dev/urandom | nawk '{print $1$2$3;}')
echo "$pkcs12_password" > ${CERT_HOST_PKCS12_PASS}
openssl pkcs12 -export \
        -password file:${CERT_HOST_PKCS12_PASS} \
        -in ${CERT_HOST_CRT} \
        -inkey ${CERT_HOST_KEY} \
-out ${CERT_HOST_PKCS12}