A TLS handshake ends with the alert certificate_unknown (46)
Fix it fast
Most common cause, 1 of 3Your Java side does not trust the certificate the peer sent
Import the CA that issued the peer's certificate into a trust store and make the JVM load it with the javax.net.ssl.trustStore, trustStoreType and trustStorePassword properties, or import it into the cacerts file of that Java installation.
keytool -importcert -alias partner-ca -file partner-ca.pem -keystore truststore.p12 -storetype PKCS12 -storepass changeit -noprompt
java -Djavax.net.ssl.trustStore=truststore.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=changeit -jar app.jarShort answer
certificate_unknown(46) means one side found a certificate unacceptable without naming why. Bouncy Castle's TlsFatalAlert says your own trust manager rejected the peer's certificate; TlsFatalAlertReceived, or OpenSSL's 14094416 alert certificate unknown seen in Indy, says the peer rejected yours. Trust the right CA, present an accepted client certificate, or update a stale pin. Applies to bctls 1.87.
Which cause do you have?
Read the exception class or the error text before anything else, because it tells you which side to fix. Then replay the handshake with openssl s_client, first without a client certificate and then with one. The first run tests whether the server's chain verifies against your CA file; the second tests whether the server accepts your certificate.
openssl s_client -connect api.example.com:443 -servername api.example.com -CAfile ca.pem -verify_return_error -brief </dev/null
openssl s_client -connect api.example.com:443 -servername api.example.com -CAfile ca.pem -cert client.crt -key client.key -verify_return_error -brief </dev/nullThen find the line you see in this list and open its fix:
- 1Your Java side does not trust the certificate the peer sent
TlsFatalAlert: certificate_unknown(46), without Received in the class name, followed by a Caused by line with a CertificateException - 2The peer refuses the client certificate you present
TlsFatalAlertReceived: certificate_unknown(46) in Bouncy Castle, or 14094416 sslv3 alert certificate unknown from an OpenSSL client such as Indy, against a service that asks for a client certificate; the first s_client run works and the second fails - 3Custom verification code refuses a certificate that verifies cleanly
s_client verifies the same chain with the same CA file without errors, but the application still raises alert 46
What does the error look like?
org.bouncycastle.tls.TlsFatalAlert: certificate_unknown(46)org.bouncycastle.tls.TlsFatalAlertReceived: certificate_unknown(46)error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknowntls alert certificate unknown (the wording of newer OpenSSL releases)
Cause 1 of 3
Your Java side does not trust the certificate the peer sent
You seeTlsFatalAlert: certificate_unknown(46), without Received in the class name, followed by a Caused by line with a CertificateException
Check
TlsFatalAlert certificate_unknown(46) without Received means your own Java trust manager rejected the peer's certificate. Bouncy Castle's JSSE provider turns any CertificateException from the trust manager, for a server or a client certificate, into that alert and sends it to the peer. Its default trust store is the file in javax.net.ssl.trustStore; with the property unset it uses lib/security/jssecacerts, then lib/security/cacerts under java.home.
keytool -cacerts -list -storepass changeit | grep -i partner
keytool -list -keystore truststore.p12 -storepass changeitFix
Import the CA that issued the peer's certificate into a trust store and make the JVM load it with the javax.net.ssl.trustStore, trustStoreType and trustStorePassword properties, or import it into the cacerts file of that Java installation.
keytool -importcert -alias partner-ca -file partner-ca.pem -keystore truststore.p12 -storetype PKCS12 -storepass changeit -noprompt
java -Djavax.net.ssl.trustStore=truststore.p12 -Djavax.net.ssl.trustStoreType=PKCS12 -Djavax.net.ssl.trustStorePassword=changeit -jar app.jarVerify
keytool lists the new alias and the application completes the handshake.
keytool -list -keystore truststore.p12 -storepass changeit -alias partner-caConfirmed by raw.githubusercontent.com
Cause 2 of 3
The peer refuses the client certificate you present
You seeTlsFatalAlertReceived: certificate_unknown(46) in Bouncy Castle, or 14094416 sslv3 alert certificate unknown from an OpenSSL client such as Indy, against a service that asks for a client certificate; the first s_client run works and the second fails
Check
TlsFatalAlertReceived certificate_unknown(46), or OpenSSL's alert certificate unknown, means the server received your client certificate and refused it. Bouncy Castle throws the Received class when a fatal alert arrives from the other side, and OpenSSL reports any received alert as an error named after it. A current OpenSSL server maps common verification failures to more specific alerts, such as unknown_ca or certificate_expired, so a plain 46 often points to a server built on Java or on its own checking code.
openssl x509 -in client.crt -noout -subject -issuer -dates
openssl x509 -in client.crt -noout -ext extendedKeyUsageFix
Ask the service which CA it accepts for client certificates, get a certificate from that CA, and send its intermediates along with it. With s_client, -cert_chain supplies those intermediates; in Java, keytool -importcert can store the CA's full chain reply under the alias of your key entry.
openssl s_client -connect api.example.com:443 -servername api.example.com -CAfile ca.pem -cert client.crt -key client.key -cert_chain intermediates.pem -verify_return_error -brief </dev/nullVerify
The handshake with the client certificate completes and prints the negotiated protocol.
openssl s_client -connect api.example.com:443 -servername api.example.com -cert client.crt -key client.key -cert_chain intermediates.pem -brief </dev/nullConfirmed by raw.githubusercontent.com
Cause 3 of 3
Custom verification code refuses a certificate that verifies cleanly
You sees_client verifies the same chain with the same CA file without errors, but the application still raises alert 46
Check
certificate_unknown(46) on a chain that s_client verifies cleanly means your own pinning or custom trust code refused it. In Bouncy Castle, the CertificateException such a trust manager throws becomes alert 46 like any other; in OpenSSL, a verify callback that returns 0 stops verification and sends a failure alert. A pinned value left over from before a certificate renewal is the usual case.
openssl s_client -connect api.example.com:443 -servername api.example.com </dev/null 2>/dev/null | openssl x509 -noout -fingerprint -sha256 -subject
grep -R -n -i -E "TrustManager|pin|fingerprint|thumbprint" src/Fix
Log the subject and fingerprint that your hook receives next to the value it expects, then update the stored pin or rule to match the renewed certificate.
openssl x509 -in server.crt -noout -fingerprint -sha256Verify
With the new value in place the application connects to the same server.
openssl s_client -connect api.example.com:443 -servername api.example.com -brief </dev/nullConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Log the peer certificate's subject and the verification result on both ends, so alert 46 is never the only clue.
- When you pin a certificate or key, add the next value before the current certificate is replaced.
- Load the same CA file in your s_client tests and in the application's trust store, so the two never disagree.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.