How to connect via TLS1_2 to smtp.office365?

  c++, office365, openssl, smtp

I have code that using TLS1_2 to connect but on phase handshake I receive error:

wrong version number

I started to trying from terminal and my request looks like this:

openssl s_client -connect smtp.office365.com:587 -tls1_2

and I reproduced the above error and full output is:

openssl s_client -connect smtp.office365.com:587 -tls1_2
CONNECTED(00000003)
140633673656208:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:s3_pkt.c:365:

no peer certificate available

No client certificate CA names sent

SSL handshake has read 5 bytes and written 7 bytes

New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg : None
Krb5 Principal: None
PSK identity: None
PSK identity hint: None
Start Time: 1632862900
Timeout : 7200 (sec)
Verify return code: 0 (ok)

Can you help me to execute this TLS1_2 version and without "-starttls smtp" command because I try to fix this connection in code.

Source: Windows Questions C++

LEAVE A COMMENT