本文整理汇总了C++中TLSv1_2_client_method函数的典型用法代码示例。如果您正苦于以下问题:C++ TLSv1_2_client_method函数的具体用法?C++ TLSv1_2_client_method怎么用?C++ TLSv1_2_client_method使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TLSv1_2_client_method函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitCTX
SSL_CTX* InitCTX(void)
{
const SSL_METHOD *method;
SSL_library_init();
OpenSSL_add_all_algorithms();
SSL_load_error_strings();
#ifdef __CASE_CLIENT
method = TLSv1_2_client_method();
#endif
#ifdef __CASE_SERVER
method = TLSv1_2_server_method();
#endif
ctx = SSL_CTX_new(method);
if ( ctx == NULL )
{
if (PRINT_SSL_ERRORS_TO_STDERR) ERR_print_errors_fp(stderr);
}
if (SSL_CTX_set_cipher_list(ctx, CIPHERS) != 1)
{
ssds_log(logERROR, "Couldnt use any ciphers\n");
return NULL;
}
return ctx;
}
示例2: es_alloc_ssl_context
struct es_ssl_context* es_alloc_ssl_context(const int ssl_type)
{
int status = ES_FAILURE;
struct es_ssl_context *context = NULL;
if(es_validate_ssl_type(ssl_type) != ES_SUCCESS)
goto exit;
context = (struct es_ssl_context*)malloc(sizeof(struct es_ssl_context));
if(!context)
goto exit;
const SSL_METHOD *method = (ssl_type == ES_SSL_SERVER)
? TLSv1_2_server_method()
: TLSv1_2_client_method();
if(!method)
goto exit;
context->context = SSL_CTX_new(method);
if(!context->context)
goto exit;
status = ES_SUCCESS;
exit:
if(status == ES_FAILURE && context)
es_free_ssl_context(&context);
return context;
}
示例3: us1190_test4
/*
* This test attempts to create a TLS 1.2 connection
* with the EST server. This should succeed.
*/
static void us1190_test4 (void)
{
LOG_FUNC_NM
;
us1190_test_sslversion(TLSv1_2_client_method(), 0);
}
示例4: get_ssl_method_name
int get_ssl_method_name(const SSL_METHOD *ssl_method, char *name, size_t len)
{
len--;
name[len] = '\0';
#ifndef OPENSSL_NO_SSL2
if (ssl_method == SSLv2_client_method()) {
strncpy(name, "SSLv2", len);
return 1;
}
#endif // #ifndef OPENSSL_NO_SSL2
if (ssl_method == SSLv3_client_method()) {
strncpy(name, "SSLv3", len);
return 2;
}
if (ssl_method == TLSv1_client_method()) {
strncpy(name, "TLSv1", len);
return 3;
}
#if OPENSSL_VERSION_NUMBER >= 0x1000008fL || OPENSSL_VERSION_NUMBER >= 0x1000100fL
if (ssl_method == TLSv1_1_client_method()) {
strncpy(name, "TLS11", len);
return 4;
}
if (ssl_method == TLSv1_2_client_method())
{
strncpy(name, "TLS12", len);
return 5;
}
#endif // #if OPENSSL_VERSION_NUMBER >= 0x1000008fL || OPENSSL_VERSION_NUMBER >= 0x1000100fL
return 0;
}
示例5: Debug
const SSL_METHOD *sycTLSv1_2_client_method(void) {
const SSL_METHOD *result;
Debug("TLSv1_2_client_method()");
result = TLSv1_2_client_method();
Debug1("TLSv1_2_client_method() -> %p", result);
return result;
}
示例6: init_ssl_methods
/*
* initialize ssl methods
*/
static void
init_ssl_methods(void)
{
LM_DBG("entered\n");
#ifndef OPENSSL_NO_SSL2
ssl_methods[TLS_USE_SSLv2_cli - 1] = (SSL_METHOD*)SSLv2_client_method();
ssl_methods[TLS_USE_SSLv2_srv - 1] = (SSL_METHOD*)SSLv2_server_method();
ssl_methods[TLS_USE_SSLv2 - 1] = (SSL_METHOD*)SSLv2_method();
#endif
ssl_methods[TLS_USE_SSLv3_cli - 1] = (SSL_METHOD*)SSLv3_client_method();
ssl_methods[TLS_USE_SSLv3_srv - 1] = (SSL_METHOD*)SSLv3_server_method();
ssl_methods[TLS_USE_SSLv3 - 1] = (SSL_METHOD*)SSLv3_method();
ssl_methods[TLS_USE_TLSv1_cli - 1] = (SSL_METHOD*)TLSv1_client_method();
ssl_methods[TLS_USE_TLSv1_srv - 1] = (SSL_METHOD*)TLSv1_server_method();
ssl_methods[TLS_USE_TLSv1 - 1] = (SSL_METHOD*)TLSv1_method();
ssl_methods[TLS_USE_SSLv23_cli - 1] = (SSL_METHOD*)SSLv23_client_method();
ssl_methods[TLS_USE_SSLv23_srv - 1] = (SSL_METHOD*)SSLv23_server_method();
ssl_methods[TLS_USE_SSLv23 - 1] = (SSL_METHOD*)SSLv23_method();
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
ssl_methods[TLS_USE_TLSv1_2_cli - 1] = (SSL_METHOD*)TLSv1_2_client_method();
ssl_methods[TLS_USE_TLSv1_2_srv - 1] = (SSL_METHOD*)TLSv1_2_server_method();
ssl_methods[TLS_USE_TLSv1_2 - 1] = (SSL_METHOD*)TLSv1_2_method();
#endif
}
示例7: init_client_SSL_CTX
static bool init_client_SSL_CTX(SSL_CTX **ctx_out) {
SSL_CTX *ctx = NULL;
assert(ctx_out);
/* Create TLS context */
const SSL_METHOD *method = NULL;
#if KINETIC_USE_TLS_1_2
method = TLSv1_2_client_method();
#else
method = TLSv1_1_client_method();
#endif
assert(method);
ctx = SSL_CTX_new(method);
if (ctx == NULL) {
ERR_print_errors_fp(stderr);
return false;
}
disable_SSL_compression();
disable_known_bad_ciphers(ctx);
*ctx_out = ctx;
return true;
}
示例8: main
int main(int argc, char *argv[])
{
SSL_CTX *ctx;
const SSL_METHOD *method = SSLv3_client_method();
int client_fd;
char *host;
char *portnum;
int bench_send = 0;
int bench_recv = 0;
int i;
enum cipher_choice cipher_choice = CIPHER_ALL;
if (argc < 3) {
printf("Usage: %s <host_ip> <portnum> [opts]\n", argv[0]);
exit(-1);
}
host = argv[1];
portnum = argv[2];
lib_init();
for (i = 3; i < argc; i++) {
if (strcmp("tls-1.2", argv[i]) == 0) {
method = TLSv1_2_client_method();
} else if (strcmp("tls-1.1", argv[i]) == 0) {
method = TLSv1_1_client_method();
} else if (strcmp("tls-1.0", argv[i]) == 0) {
method = TLSv1_client_method();
} else if (strcmp("ssl-3.0", argv[i]) == 0) {
method = SSLv3_client_method();
} else if (strcmp("bench-send", argv[i]) == 0) {
bench_send = atoi(argv[++i]);
} else if (strcmp("bench-recv", argv[i]) == 0) {
bench_recv = atoi(argv[++i]);
} else {
printf("warning: unknown option: \"%s\"\n", argv[i]);
}
}
ctx = client_init(method, cipher_choice);
client_fd = connect_socket(host, atoi(portnum));
printf("[status] connected. handshaking\n");
SSL *ssl;
ssl = SSL_new(ctx);
SSL_set_fd(ssl, client_fd);
if (bench_send > 0 || bench_recv > 0)
benchmark(ssl, bench_send, bench_recv);
else
process(ssl);
close(client_fd);
SSL_CTX_free(ctx);
return 0;
}
示例9: SSL_CTX_new
void Context::createSSLContext()
{
if (SSLManager::isFIPSEnabled())
{
_pSSLContext = SSL_CTX_new(TLSv1_method());
}
else
{
switch (_usage)
{
case CLIENT_USE:
_pSSLContext = SSL_CTX_new(SSLv23_client_method());
break;
case SERVER_USE:
_pSSLContext = SSL_CTX_new(SSLv23_server_method());
break;
#if defined(SSL_OP_NO_TLSv1) && !defined(OPENSSL_NO_TLS1)
case TLSV1_CLIENT_USE:
_pSSLContext = SSL_CTX_new(TLSv1_client_method());
break;
case TLSV1_SERVER_USE:
_pSSLContext = SSL_CTX_new(TLSv1_server_method());
break;
#endif
#if defined(SSL_OP_NO_TLSv1_1) && !defined(OPENSSL_NO_TLS1)
/* SSL_OP_NO_TLSv1_1 is defined in ssl.h if the library version supports TLSv1.1.
* OPENSSL_NO_TLS1 is defined in opensslconf.h or on the compiler command line
* if TLS1.x was removed at OpenSSL library build time via Configure options.
*/
case TLSV1_1_CLIENT_USE:
_pSSLContext = SSL_CTX_new(TLSv1_1_client_method());
break;
case TLSV1_1_SERVER_USE:
_pSSLContext = SSL_CTX_new(TLSv1_1_server_method());
break;
#endif
#if defined(SSL_OP_NO_TLSv1_2) && !defined(OPENSSL_NO_TLS1)
case TLSV1_2_CLIENT_USE:
_pSSLContext = SSL_CTX_new(TLSv1_2_client_method());
break;
case TLSV1_2_SERVER_USE:
_pSSLContext = SSL_CTX_new(TLSv1_2_server_method());
break;
#endif
default:
throw Poco::InvalidArgumentException("Invalid or unsupported usage");
}
}
if (!_pSSLContext)
{
unsigned long err = ERR_get_error();
throw SSLException("Cannot create SSL_CTX object", ERR_error_string(err, 0));
}
SSL_CTX_set_default_passwd_cb(_pSSLContext, &SSLManager::privateKeyPassphraseCallback);
Utility::clearErrorStack();
SSL_CTX_set_options(_pSSLContext, SSL_OP_ALL);
}
示例10: evssl_init
SSL_CTX *
evssl_init()
{
DH *dh;
SSL_CTX *ctx;
SSL_load_error_strings();
SSL_library_init();
RAND_poll();
if ((passport = pki_passport_load_from_file(cfg->cert,
cfg->pkey, cfg->tcert)) == NULL) {
return NULL;
}
if ((ctx = SSL_CTX_new(TLSv1_2_client_method())) == NULL) {
jlog(L_ERROR, "SSL_CTX_new failed");
return NULL;
}
if ((dh = get_dh_1024()) == NULL) {
jlog(L_ERROR, "get_dh_1024 failed");
goto out;
}
if ((SSL_CTX_set_tmp_dh(ctx, dh)) == 0) {
jlog(L_ERROR, "SSL_CTX_set_tmp_dh failed");
goto out;
}
//SSL_CTX_set_cipher_list(ctx, "ECDHE-ECDSA-AES256-GCM-SHA384");
if ((SSL_CTX_set_cipher_list(ctx, "AES256-GCM-SHA384")) == 0) {
jlog(L_ERROR, "SSL_CTX_set_cipher failed");
goto out;
}
SSL_CTX_set_cert_store(ctx, passport->cacert_store);
if ((SSL_CTX_use_certificate(ctx, passport->certificate)) == 0) {
jlog(L_ERROR, "SSL_CTX_use_certificate failed");
goto out;
}
if ((SSL_CTX_use_PrivateKey(ctx, passport->keyring)) == 0) {
jlog(L_ERROR, "SSL_CTX_use_PrivateKey failed");
goto out;
}
DH_free(dh);
return ctx;
out:
DH_free(dh);
SSL_CTX_free(ctx);
return NULL;
}
示例11: TLSv1_2_client_method
static const SSL_METHOD *tls1_get_client_method(int ver)
{
if (ver == TLS1_2_VERSION)
return TLSv1_2_client_method();
if (ver == TLS1_1_VERSION)
return TLSv1_1_client_method();
if (ver == TLS1_VERSION)
return TLSv1_client_method();
return NULL;
}
示例12: ssl23_get_client_method
static const SSL_METHOD *
ssl23_get_client_method(int ver)
{
if (ver == TLS1_VERSION)
return (TLSv1_client_method());
if (ver == TLS1_1_VERSION)
return (TLSv1_1_client_method());
if (ver == TLS1_2_VERSION)
return (TLSv1_2_client_method());
return (NULL);
}
示例13: SSL_CTX_new
/*
*given a socketfd, tries to create TLS ctx
*returns a SSL connection on success
*/
SSL *add_tls_cli(int sockfd)
{
/* SSL/TLS stuff */
SSL_CTX *tls;
SSL *ctls;
tls = SSL_CTX_new(TLSv1_2_client_method());
ctls = SSL_new(tls);
SSL_set_fd(ctls,sockfd);
/* end SSL/TLS stuff */
return ctls;
}
示例14: SSLv23_server_method
const SSL_METHOD *anubis_string_to_SSL_METOHD(const char *method, int role) {
if(!method)
return NULL;
if(!strcasecmp(method, "SSLv23"))
return role == ANUBIS_ROLE_SERVER ?
SSLv23_server_method() :
role == ANUBIS_ROLE_CLIENT ? SSLv23_client_method() : NULL;
#ifndef OPENSSL_NO_SSL2_METHOD
if(!strcasecmp(method, "SSLv2"))
return role == ANUBIS_ROLE_SERVER ?
SSLv3_server_method() :
role == ANUBIS_ROLE_CLIENT ? SSLv3_client_method() : NULL;
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
if(!strcasecmp(method, "SSLv3"))
return role == ANUBIS_ROLE_SERVER ?
SSLv3_server_method() :
role == ANUBIS_ROLE_CLIENT ? SSLv3_client_method() : NULL;
#endif
if(!strcasecmp(method, "TLSv1.0"))
return role == ANUBIS_ROLE_SERVER ?
TLSv1_server_method() :
role == ANUBIS_ROLE_CLIENT ? TLSv1_client_method() : NULL;
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
if(!strcasecmp(method, "TLSv1.1"))
return role == ANUBIS_ROLE_SERVER ?
TLSv1_1_server_method() :
role == ANUBIS_ROLE_CLIENT ? TLSv1_1_client_method() : NULL;
if(!strcasecmp(method, "TLSv1.2"))
return role == ANUBIS_ROLE_SERVER ?
TLSv1_2_server_method() :
role == ANUBIS_ROLE_CLIENT ? TLSv1_2_client_method() : NULL;
#endif
/*
if(!strcasecmp(method, "DTLS1.0"))
return role == ANUBIS_ROLE_SERVER ?
DTLSv1_server_method() :
role == ANUBIS_ROLE_CLIENT ? DTLSv1_client_method() : NULL;
if(!strcasecmp(method, "DTLS1.2"))
return role == ANUBIS_ROLE_SERVER ?
DTLSv1_2_server_method() :
role == ANUBIS_ROLE_CLIENT ? DTLSv1_2_client_method() : NULL;
if(!strcasecmp(method, "DTLS"))
return role == ANUBIS_ROLE_SERVER ?
DTLS_server_method() :
role == ANUBIS_ROLE_CLIENT ? DTLS_client_method() : NULL;
*/
return NULL;
}//end anubis_string_to_SSL_METOHD
示例15: switch
static const SSL_METHOD *swSSL_get_method(int method)
{
switch (method)
{
#ifndef OPENSSL_NO_SSL3_METHOD
case SW_SSLv3_METHOD:
return SSLv3_method();
case SW_SSLv3_SERVER_METHOD:
return SSLv3_server_method();
case SW_SSLv3_CLIENT_METHOD:
return SSLv3_client_method();
#endif
case SW_SSLv23_SERVER_METHOD:
return SSLv23_server_method();
case SW_SSLv23_CLIENT_METHOD:
return SSLv23_client_method();
case SW_TLSv1_METHOD:
return TLSv1_method();
case SW_TLSv1_SERVER_METHOD:
return TLSv1_server_method();
case SW_TLSv1_CLIENT_METHOD:
return TLSv1_client_method();
#ifdef TLS1_1_VERSION
case SW_TLSv1_1_METHOD:
return TLSv1_1_method();
case SW_TLSv1_1_SERVER_METHOD:
return TLSv1_1_server_method();
case SW_TLSv1_1_CLIENT_METHOD:
return TLSv1_1_client_method();
#endif
#ifdef TLS1_2_VERSION
case SW_TLSv1_2_METHOD:
return TLSv1_2_method();
case SW_TLSv1_2_SERVER_METHOD:
return TLSv1_2_server_method();
case SW_TLSv1_2_CLIENT_METHOD:
return TLSv1_2_client_method();
#endif
case SW_DTLSv1_METHOD:
return DTLSv1_method();
case SW_DTLSv1_SERVER_METHOD:
return DTLSv1_server_method();
case SW_DTLSv1_CLIENT_METHOD:
return DTLSv1_client_method();
case SW_SSLv23_METHOD:
default:
return SSLv23_method();
}
return SSLv23_method();
}