When you create a SSL_CTX, using the function SSL_CTX_new, you need to pass as argument a method, as per the documentation:
https://www.openssl.org/docs/ssl/SSL_CTX_new.html
All methods have three variations: generic, client and server.
For example, you have TLSv1_method, TLSv1_server_method, TLSv1_client_method.
My questions are: when should I use the specific (client/server) methods? What are they good for? Can I always exchange then with the generic method?
I don't believe there is a significant difference when selecting a
method
. You can use the generic method for a client and a server.I believe the client are server methods provide a hint for use later in the library. From
struct ssl_st
inssl.h
:Interestingly, there's just one generic macro that handles them (generic, client, server). For example, the SSLv23 methods:
Then, in
ssl/ssl_locl.h
:Usually, you want something like the following to ensure "TLS 1.0 and above" rather than picking a specific method:
The library will do the right thing and pick the highest protocol (TLS 1.2, TLS 1.1, etc) and the strongest cipher (with some hand waiving).
The RFCs don't specify who "picks" the cipher, and OpenSSL leaves it to the client by default. If you are running the server, then you can use
SSL_OP_CIPHER_SERVER_PREFERENCE
to ensure your server picks the cipher suite rather than taking the client's first choice. This is important because some clients are braindead and will select RSA key transport, RC4 and MD5 (and other weak/wounded/broken configurations).If you use
SSL_OP_CIPHER_SERVER_PREFERENCE
, then you need to make sure you have selected the appropriate cipher suites. I'd expect to see a cipher suite string withHIGH
,!ADH
,!RC4
,!MD5
, etc.