I use the following code to setup SSLHandler for POP3/SMTP sending/receiving app:
IdSSLHandler->SSLOptions->Mode = sslmClient;
IdSSLHandler->SSLOptions->Method = slvSSLv23;
IdSSLHandler->SSLOptions->SSLVersions = TIdSSLVersions() << sslvSSLv3 << sslvTLSv1 << sslvTLSv1_1 << sslvTLSv1_2;
So, the above code is supposed to support SSL 3, TLS 1, TLS 1.1 and TLS 1.2 automatically. This does not work well and reports "wrong version" error. When the SSLVersions
line is removed then it works but by defaults it includes sslvSSLv2
which I don't want to support. It is the same like:
IdSSLHandler->SSLOptions->Mode = sslmClient;
IdSSLHandler->SSLOptions->Method = slvSSLv23;
IdSSLHandler->SSLOptions->SSLVersions = TIdSSLVersions() << sslvSSLv2 << sslvSSLv3 << sslvTLSv1 << sslvTLSv1_1 << sslvTLSv1_2;
For some reason, this works and the above does not on same server. I know that slvSSLv23
is a kind of "use any available version" value. So why does it not work with above code where version 2 is not present?
Additionally, I can use TSL1 which seems to be widely deployed, but if the server supports 1.1 or 1.2 then my code won't be using more recent versions but will force 1.0 version unless something like above is used.
I would like to make an initialization with the following goals:
- compatible with all servers, regardless if they use v3, tls1, tls1.1 or tls1.2
- automatically use the most recent version and use lower version if more recent is not available on the server but not lower than version 3 - fail/exception if version is lower than 3
I thought the first version of the code would provide that but it reports version error. Are the above goals possible or a user-setting must be provided to select SSL version to use?