I’m trying to publish on Solace queue with Client Certificate Authentication using self signed certificate. But getting below error:
Remote addr: mr-connection-dcnuo3u5bkz.messaging.solace.cloud Remote port: 55443) - ) com.solacesystems.jcsmp.JCSMPErrorResponseException: 401: Certificate Error [Subcode:1]
at com.solacesystems.jcsmp.protocol.impl.TcpChannel.executePostOnce(TcpChannel.java:235)
at com.solacesystems.jcsmp.protocol.impl.ChannelOpStrategyClient.performOpen(ChannelOpStrategyClient.java:101)
at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.performOpenSingle(TcpClientChannel.java:428)
at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.access$800(TcpClientChannel.java:124)
at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel$ClientChannelConnect.call(TcpClientChannel.java:2661)
at com.solacesystems.jcsmp.protocol.impl.TcpClientChannel.open(TcpClientChannel.java:404)
at com.solacesystems.jcsmp.impl.JCSMPBasicSession.sniffRouter(JCSMPBasicSession.java:423)
at com.solacesystems.jcsmp.impl.JCSMPBasicSession.connect(JCSMPBasicSession.java:1310)
Below is the code snippet I’m using to publish over Solace Queue:
final JCSMPProperties properties = new JCSMPProperties();
properties.setProperty(JCSMPProperties.HOST, host); // host:port
properties.setProperty(JCSMPProperties.VPN_NAME, vpnName); // message-vpn
For step 1, please ensure you added the Certificate Authorities (CA) into the client certificate authority list, not the client certificate itself.
For self-signed, this should be the (self-created)CA certificate used to sign the client certificate.
in step 9, the certificate is for your client, it is not the Certificate Authorities.
You can read this doc on how to generate self-signed Root CA(the contoso.crt file), then use it to create(sign) a certificate(for the client). You should upload the content of your Root CA in step 9. So that the broker can authenticate your client when the client present its certificate.
Hi Sahil, sorry for the late response. I was quite overloaded recently.
I haven’t check your steps yet, but after adding the certificate authority to the broker, you also need to add a username for the client that matches the common name in our client certificate.
You can follow this document page:
Pay attention to the section “Add the Client Username from a Client Certificate”
to create the client1.key and clientCert1.pem. Then I used the following commands to import the certificate to a keystore:
openssl pkcs12 -export -in clientCert1.pem -inkey client1.key -out client1Cert.p12 -name “client1Cert”
keytool -importkeystore -srckeystore client1Cert.p12 -srcstoretype pkcs12 -destkeystore keystore.jks
I used the same code as you shared above, and I was able to connect to the broker.
there is an error when you generating the certificate. You can follow the steps in the above link to redo.
Have you checked whether the DigiCertGlobalRootCA.crt.pem is imported into your Java’s default Truststore? By default it should be there, but you can use this command to export the cert list in your truststore and double check.
keytool -list -v -keystore file-to-java-cacerts > certList.txt
“CN=DigiCert Global Root CA” should present in the list