'TLS client not failing the handshake even when SNI is not matching with subject received in server-certificate
I'm trying to understand the TLS handshake. In the client-hello am sending the SNI-extention's hostname set to say "server1". But the TLS server is sending a server-certificate with the subject/common-name/FQDN as "random-server". I'm expecting that the TLS client should fail the certificate validation and should teardown the connection. But, I see the connection is not teared-down and the certificate validation also passes.
Am using "openssl s_server" as TLS server and "openssl s_client" as TLS client. Below are the commands:-
openssl s_server -key serverkey.pem -cert servercert.pem -accept 4433 -msg -debug -state
openssl s_client -servername tls-server -connect localhost:4433 -state -debug -msg -tlsextdebug -CAfile cacert.pem
Important logs on server side :-
TLS client extension "server name" (id=0), len=18
0000 - 00 10 00 00 0d 72 61 6e-64 6f 6d 2d 73 65 72 76 .....random-serv
0010 - 65 72
SSL_accept:SSLv3 write server hello A
>>> TLS 1.2 Handshake [length 0540], Certificate
...
...
0120 - 30 11 06 03 55 04 03 0c-0a 74 6c 73 2d 73 65 72 0...U....tls-ser
0130 - 76 65 72 30 82 01 22 30-0d 06 09 2a 86 48 86 f7 ver0.."0...*.H..
Important logs on Client side :-
-----END CERTIFICATE-----
subject=/C=IN/ST=KA/L=Bangalore/O=xxx/CN=tls-server
Verify return code: 0 (ok)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
