ClientHello Retransmitted many times followed by TCP DUP ACK during SSL handshake - ssl

we have one client and server our application running as bridge between client and server.
our module responsible for forwarding the traffic between client and server.
During SSL handshake i am trying to interrupt the client hello and respond to the client with serverhello.
we are able to interrupt and send the serverhello to the client but SSL handshake is failed.
captured the packets during SSL handshake.
i could see Server hello reached to the client interface but Client machine retransmitting the clienthello again and again could any one help on this what went wrong why the client not processing serverhello.

Related

Protocol still is tcp after configured the kafka two-way SSL

After configured the kafka (kafka_2.13-2.4.1) with two-way SSL per the document https://kafka.apache.org/documentation/#security_ssl, when sent message by the kafka-console-producer.sh, the message can be received by consumer (kafka-console-consumer.sh).
But when use the tcpdump capture the network traffic, the protocol still is TCP, not TLSor SSL.
When added the -Djava.net.debug to the kafka-console-producer.sh, the two-way SSL handshakes can be printed (from ClientHello to server finishng).
Why I cannot get the tsl protocol? Is it wrong way?

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.

After enabling TLSv1.2 in hostapd(an Integrated EAP RADIUS server),"fatal alert:decode error" is received from client(wpa_supplicant) during EAP-TLS

I am in a big issue regarding TLSv1.2 and unable to resolve this.
Scenario:
Hostapd should act as an integrated EAP server.I have an openwrt device on which hostapdv2.6-devel is running.
2.Wpa_Supplicant is acting as a client and should talk to hostapd for successful authentication.wpa_supplicantv2.6-devel is running on a different openwrt device.
3.Two way SSL handshake(EAP-TLS) should happen successfully and hostapd should authenticate the client device without any issue.
4.Requirement is that this communication should take place on TLSv1.2 i.e. server (hostapd)is bound to send TLSv1.2.
Configuration:
EAP server(hostapd configuration):
1.Since by default server is sending TLSv1.0 to the client so I made it to send TLSv1.2 forcefully by recompiling the package for TLSv12 and install again on the router.
2.Created a configuration file, which has all the server certificate, ca certificate chain eap_server=1 etc.
3.Started the hostapd process on the device successfully.
client configuration(wpa_supplicant):
1.Created a configuration file, which has all client certificate, CA chain, identity, SSID etc.
2.Started the wpa_supplicant on the device successfully.
SSL transactions:
1.client send client hello message and TLSv1.2 in it.
2.Server responds with server hello message and TLSv1.2
3.Server sends its certificate, serverkeyexchange, certificate request message.
4.Afterward a fatal alert occurs "decode_error" and no more transaction are seen and authentication gets failed.
Please see the wireshark capture below.
ClientHello
ServerHello
Alert Message
Kindly help me to resolve this issue as its making my life difficult.
Please let me know if any other information is required.
Thanks.

TLS handshake over websockets

I've set out to handle tls operations manually on a websockets server, due to the cockeyed way php supports listening on secured transports.From RFC6455:
If /secure/ is true, the client MUST perform a TLS handshake over the
connection after opening the connection and before sending the
handshake data [RFC2818]. If this fails (e.g., the server's
certificate could not be verified), then the client MUST Fail the
WebSocket Connection and abort the connection. Otherwise, all
further communication on this channel MUST run through the encrypted
tunnel [RFC5246].
According to this, the first thing I should receive is the clientHello message which signifies the beginning of a TLS handshake.But all I receive on the server is the websocket handshake request, encrypted.
I am baffled by this.Is there no TLS handshake at all?

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"