Configuring SSL Using the BrokerConnectionDescriptor Class
For your Java client, use the BrokerConnectionDescriptor.setSSLCertificate method to configure SSL security, prior to creating a BrokerClient.
When a BrokerConnectionDescriptor is created, the certificate file will be set to null by default. Therefore, you must use the setSSLCertificate method before creating a Broker client if you want to configure SSL security.
Return Type | Method Signature and Description |
void | public void setSSLcertificate( string keystore_file, string truststore_file, KeystoreType keystore_type, TruststoreType truststore_type, string password) throws BrokerException; Where: keystore_file is the keystore file path. truststore_file is the truststore file path. keystore_type is the keystore type. truststore_type is the truststore type. password is the password. |
BrokerSSLCertificate | getSSLCertificate( string keystore_file, string truststore_file, KeystoreType keystore_type, TruststoreType truststore_type, string password) throws BrokerException Where: keystore_file is the keystore file path. truststore_file is the truststore file path. keystore_type is the keystore type. truststore_type is the truststore type. password is the password. Use this method to get the Entrust SSL certificate. |
TruststoreType | getSSLTruststoreType() |
String | getSSLTruststore() |
KeystoreType | getSSLKeystoreType() |
String | getSSLKeystore() |
The following code sample shows how to configure the settings for Broker SSL authentication using the BrokerConnectionDescriptor.setSSLCertificate method, passing in the parameters described in the previous table:
// Build the connection descriptor.
BrokerConnectionDescriptor connectionDescriptor =
new BrokerConnectionDescriptor()
String keystore_file = “C:\mykeystore.p12”;
String truststore_file = “C:\mytruststore.jks”;
KeystoreType keystoreType = “KeystoreType.p12”;
TruststoreType truststoreType = “TruststoreType.jks”;
String password = “1234”;
connectionDescriptor.setSSLCertificate (keystore_file,
truststore_file,
keystoreType,
truststoreType,
password)
// Set other properties for the connectionDescriptor, if needed.
// Create a new Broker client.
client = new BrokerClient (brokerHost, brokerName, clientName,
clientGroup, ... , “publisher”, connectionDescriptor);