编写连接业务层的代码。

This commit is contained in:
zhengchao
2019-05-18 18:27:13 +08:00
parent 3f305a9e88
commit 61bc647d1f
8 changed files with 249 additions and 63 deletions

View File

@@ -4,6 +4,7 @@
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include <openssl/crypto.h>
#include <openssl/engine.h>
@@ -150,6 +151,45 @@ void ssl_openssl_version(void)
#endif /* !SSL_OP_TLS_ROLLBACK_BUG */
fprintf(stderr, "\n");
}
int sslver_str2num(const char * version_str)
{
int sslversion = -1;
assert(OPENSSL_VERSION_NUMBER >= 0x10100000L);
/*
* Support for SSLv2 and the corresponding SSLv2_method(),
* SSLv2_server_method() and SSLv2_client_method() functions were
* removed in OpenSSL 1.1.0.
*/
if (!strcmp(version_str, "ssl3"))
{
sslversion = SSL3_VERSION;
}
else if (!strcmp(version_str, "tls10") || !strcmp(version_str, "tls1"))
{
sslversion = TLS1_VERSION;
}
else if (!strcmp(version_str, "tls11"))
{
sslversion = TLS1_1_VERSION;
}
else if (!strcmp(version_str, "tls12"))
{
sslversion = TLS1_2_VERSION;
}
else if (!strcmp(version_str, "tls13"))
{
sslversion = TLS1_3_VERSION;
}
else
{
sslversion = -1;
}
return sslversion;
}
/*
* 1 if OpenSSL has been initialized, 0 if not. When calling a _load()