SSL/TLS Handshake failed - Unrecognized Name - ssl

I was trying for create a simple ssl server/client communication. I am running client now and monitor the Wireshark log. I am able to see the Client Hello message also verified the packet format ciphers and another parameters are correct in client side. but instead of server hello message I am getting
"Alert (Level: Fatal, Description: Unrecognized Name) "
I need the support for what is the root cause of the issue also I need support for how to fix the issue.

Related

What exactly means Indy underlying error 14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown

What exactly happens in Indy when a simple HTTPS request from a browser causes the debugger to break with this error:
Project PMS_COM.exe raised exception class EIdOSSLUnderlyingCryptoError with message 'Error accepting connection with SSL.
error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown'.
Some on the Internet say that this is a client certificate error, but there is no client certificate! There is only the server-side certificate.
But if I understood wrong and it is a client-side error, then why does it cause an exception on the server side?
Additionally I don't understand how to intercept such kind of errors. EIdOSSLUnderlyingCryptoError seems to happen somewhere in Indy with no chance to catch it in my code.
EIdOSSLUnderlyingCryptoError is an Indy exception wrapping an OpenSSL error message.
Per SSLv3 alert certificate unknown (4279556):
The SSL library sends an alert back to the system telling the certificate chain was invalid.
The message section that says "sslv3 alert certificate unknown" usually refers to the intermediate certificate in a chain of certificates. That certificate is expired, invalid or not trusted by one or more systems involved in the SSL/TLS communication.
In this case, the client (browser) is sending an alert to your server to abort the TLS handshake because your server certificate is invalid. That alert is triggering the EIdOSSLUnderlyingCryptoError exception within the server's code. The server will handle the error for you, by closing its end of the TCP connection that failed the handshake, and terminate/recycle the worker thread which owns that TCP socket.
If you want to catch the error, you can use the server's OnException event, which is triggered in the same thread that owns the TCP connection that failed the TLS handshake.

TLS handshake fail, but communication is not closed

I have TLS program and I did some experiments on it.
I start confidential TLS server session and try to connect to it with pure Telnet client.
As expected, the handshake failed and the server is available to the next client but on the Telnet client side I didn't receive any indication that the handshake failed and that the server is accepting other clients.
I can see in Wireshark that even after the handshake failed the Telnet client can send strings; I see [PSH, ACK] from the client answered by [ACK] from the server.
Adding Wireshark snapshot, Telnet failed the handshake, Telnet keep sending messages, followed by success in the TLS handshake and more Telnet messages:
Why is the server ACKing the Telnet client if the handshake failed and he is accepting other clients?
As expected, the handshake failed ...
I cannot see a failed TLS handshake in the packet capture and I'm not sure how you come to this conclusion.
All I can see that the client on source port 60198 (presumable your telnet) is sending 3 bytes several times and the server just ACK'ing these without sending anything back and without closing the connection. Likely the server is still expecting data in the hope that at some time it will be a complete TLS record. Only then it will be processed by the TLS stack and then it might realize that something is wrong with the client.
... the server is available to the next client
It is pretty normal for a server to handle multiple clients in parallel. In contrary, it would be unusual if the server could not do this.

sending xmlhttprequest to javame securesocketserver

I've written a MIDlet server that handle tcp inputstream. I send xmlhttprequest with an http:// url from a html web page and it works fine. I want to do the same with an https url.
with my secureserverconnection instancied by a connector.open the accecptandopen() method return an exception.
handshake client send
As you can see the xmlhttprequest send an handshake hello but I've notices tls1.2 protocol then tls1.0 protocol and finally tls1.2.
Is it normal having 2 different protocol sent by the client. It is the first phase of the handshake protocol.
My Midlet java server respond with an Alert and a a "ssl3_get_client_hello:no shared cipher" error (IOException)
IOexception capture
I've specified the connector options like this : cipher : TLS_RSA_WITH_AES_128_GCM_SHA256 and TLSv1.2 protocol
tlsv1.2 server response
Have someone ever done it or can explain me why the cipher handshake is in error?
Yes it is normal for the client to try both protocols. The most likely scenario is that your device simply lacks any valid certificates, since J2ME devices are so old.
See:
"ssl3_get_client_hello:no shared cipher" in server depending on server certificate and key

Cause of TLS Handshake failed when attemtpting to make TLS call

I am attempting to make a secure call between two virtual machines using pjsua program from pjsip installation. I start the program on each node via :
pjsua-x86_64-unknown-linux-gnu --use-tls
I then enter m to make call and submit : sip:xxx.xxx.xx.x:5061;transport=TLS
On the receiving side I see :
Handshake failed in accepting xxx.xxx.xx.x:58392: no shared cipher
On the dialing side I am seeing :
Failed to send Request msg INVITE/cseq=17559 (tdta0x1ab89e0)! err=495040 (sslv3 alert handshake failure)
Can anyone help me to understand why this is happening?
Looks like there is a mismatch between the cipher configuration of the server(receiving side in your case) and client (dialing side in your case).
The error no shared cipher (alert 40) says that there is not at least any one of the cipher used by client available at the server side
You need to look into the call for SSL_CTX_set_cipher_list (If you are using OpenSSL) API on both the ends.
Try to configure the common cihpers on both client and server machines.
Some times you may get the same error (no chared cipher) for unavailability of the cipher which is used by public certificates. better verify the first step then verify your certificate algorithm.
I too had faced the similar problem for my client server configuration.
here is a reference:
"no shared cipher" error with python and OpenSSL

how to verify if java sends the client certificate in a mutual auth scenario

I setup 2way ssl with Camel and CXF using the http conduit element etc.
I make a webservice call to an external party. All certificates are correctly installed (incoming traffic is succesfull, this is configured in Tomcat). After this post about secure renegotiation I finally received a response from the other party: HTTP response 403, forbidden.
I've been debugging with javax.net.debug=all and this excellent explanation.
I can see in the logging that a secure connection is succesfully setup:
*** Finished
verify_data: { 141, 25, 184, 254, 93, 9, 10, 48, 135, 161, 213, 57 }
***
%% Cached client session: [Session-2, SSL_RSA_WITH_RC4_128_MD5]
and no other errors or warnings. How can I verify if my client certificate is sent to the server? (I can't use Wireshark but I have the javax.net.debug logging)
I found the answer in this post and by comparing the javax.net.debug output to the client auth example.
I don't see CertificateVerify in my log, only the one way ssl steps, so there is no client certificate sent.
The cause was that I copied the CXF http conduit example from their website, but somehow the ciphersuite filter it contained was too strict.
I needed to track this down and found the following.
In Java 11, I enabled SSL logging by adding this option to the tomcat server process I was using:
-Djavax.net.debug=ssl:handshake:verbose:keymanager.
Next, I ran my test and studied the logs. The general format of all messages begin like this (so I won't repeat this because it clutters up the important content).
javax.net.ssl|DEBUG|22|http-bio-8443-exec-1|2023-02-06 18:01:35.705 GMT|CertificateMessage.java:366|Produced ClientHello handshake message
Client Side Logs: Successful mutual authentication
The following shows the SSL handshake messages that occurred during a successful two way certificate authentication.
Produced ClientHello handshake message
Consuming ServerHello handshake message
Consuming server Certificate handshake message <<< Receiving Server cert
Consuming ECDH ServerKeyExchange handshake message
Consuming CertificateRequest handshake message <<< Server asking for client cert
Consuming ServerHelloDone handshake message
Produced client Certificate handshake message <<< Sending client cert
Produced ECDHE ClientKeyExchange handshake message
Produced CertificateVerify handshake message
Produced ChangeCipherSpec message
Produced client Finished handshake message
Consuming ChangeCipherSpec message
Consuming server Finished handshake message
I highlighted the lines that show the server cert being received and the client cert being sent. I should note that the above is the logs as viewed on the client side of the connect.
The SSL Spec (See https://www.rfc-editor.org/rfc/rfc5246#section-7.4.6) says:
This [the Client Certificate message] is the first message the client can send after receiving a
ServerHelloDone message. This message is only sent if the server
requests a certificate
And once the ClientKeyExchange message is sent, we know that no client certificate was sent because again the spec says:
This message is always sent by the client. It MUST immediately
follow the client certificate message, if it is sent. Otherwise,
it MUST be the first message sent by the client after it receives
the ServerHelloDone message.
Since the ServerHelloDone message was printed, and then the ClientKeyExchange message was printed, therefore the ClientCertificate message was not sent because if it were being sent it needed to be sent immediately after the SeverHelloDone and before the ClientKeyExchange.
This test was performed using Java 11. I don't have the web libraries handy but this was not a SpringBoot application.
Server Side Logs: Successful mutual authentication with certs
For completeness, the following shows the messages that are logged by the server side of the two way authentication using certificates.
Consuming ClientHello handshake message
Ignore unavailable extension: supported_versions
Produced ServerHello handshake message
Produced server Certificate handshake message <<< Sending server cert
Produced ECDH ServerKeyExchange handshake message
Produced CertificateRequest handshake message <<< Request client send cert
Produced ServerHelloDone handshake message
Consuming client Certificate handshake message << Receiving clients cert
Consuming ECDHE ClientKeyExchange handshake message
Consuming CertificateVerify handshake message
Consuming ChangeCipherSpec message
Consuming client Finished handshake message
Produced ChangeCipherSpec message
Produced server Finished handshake message
Summary
This answer highlights the messages logged for the two way (aka mutual) authentication using X.509 certificates in a Java web application that both received incoming requests (and required mutual authentication) and making a REST call to another server that also required two way authentication.
Some of the log messages shown contain a large amount of additional information such as the actual certificate information and detailed values from the SSL specification. None of that data is shown because it makes it harder to see the important messages and it is not needed to understand the answer.
If you needed to see exactly what was sent in a certificate then the detailed logs provide that information.
Later, I tried this with a SpringBoot application using spring-boot-starter-parent:2.7.3 and it also worked when running with
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Djavax.net.debug=ssl:handshake:verbose:keymanager"