tls-socket: Allow configuring both minimum and maximum TLS versions

This commit is contained in:
Tobias Brunner
2021-02-12 11:45:44 +01:00
parent c4576a1f57
commit a7f2818832
7 changed files with 18 additions and 14 deletions
+5 -5
View File
@@ -405,8 +405,9 @@ METHOD(tls_socket_t, destroy, void,
* See header
*/
tls_socket_t *tls_socket_create(bool is_server, identification_t *server,
identification_t *peer, int fd, tls_cache_t *cache,
tls_version_t max_version, bool nullok)
identification_t *peer, int fd,
tls_cache_t *cache, tls_version_t min_version,
tls_version_t max_version, bool nullok)
{
private_tls_socket_t *this;
tls_purpose_t purpose;
@@ -442,12 +443,11 @@ tls_socket_t *tls_socket_create(bool is_server, identification_t *server,
this->tls = tls_create(is_server, server, peer, purpose,
&this->app.application, cache);
if (!this->tls)
if (!this->tls ||
!this->tls->set_version(this->tls, min_version, max_version))
{
free(this);
return NULL;
}
this->tls->set_version(this->tls, TLS_1_0, max_version);
return &this->public;
}