当前位置: 首页>>代码示例>>C++>>正文


C++ SSL_get_ex_new_index函数代码示例

本文整理汇总了C++中SSL_get_ex_new_index函数的典型用法代码示例。如果您正苦于以下问题:C++ SSL_get_ex_new_index函数的具体用法?C++ SSL_get_ex_new_index怎么用?C++ SSL_get_ex_new_index使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SSL_get_ex_new_index函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SSL_get_app_data2_idx

int SSL_get_app_data2_idx(void)
{
   static int app_data2_idx = -1;

   if (app_data2_idx < 0) {
      app_data2_idx = SSL_get_ex_new_index(0,
           "Second Application Data for SSL", NULL, NULL, NULL);
      app_data2_idx = SSL_get_ex_new_index(0,
           "Second Application Data for SSL", NULL, NULL, NULL);
   }
   return(app_data2_idx);
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:12,代码来源:ssl_util_ssl.c

示例2: SSL_library_init

void SSLContext::initializeOpenSSLLocked() {
  if (initialized_) {
    return;
  }
  SSL_library_init();
  SSL_load_error_strings();
  ERR_load_crypto_strings();
  // static locking
  locks.reset(new SSLLock[::CRYPTO_num_locks()]);
  for (auto it: lockTypes) {
    locks[it.first].lockType = it.second;
  }
  CRYPTO_set_id_callback(callbackThreadID);
  CRYPTO_set_locking_callback(callbackLocking);
  // dynamic locking
  CRYPTO_set_dynlock_create_callback(dyn_create);
  CRYPTO_set_dynlock_lock_callback(dyn_lock);
  CRYPTO_set_dynlock_destroy_callback(dyn_destroy);
  randomize();
#ifdef OPENSSL_NPN_NEGOTIATED
  sNextProtocolsExDataIndex_ = SSL_get_ex_new_index(0,
      (void*)"Advertised next protocol index", nullptr, nullptr, nullptr);
#endif
  initialized_ = true;
}
开发者ID:axiak,项目名称:folly,代码行数:25,代码来源:SSLContext.cpp

示例3: ssl_init

int ssl_init(void) { /* init SSL before parsing configuration file */
    SSL_load_error_strings();
    SSL_library_init();
    index_cli=SSL_get_ex_new_index(0, "cli index",
        NULL, NULL, NULL);
    index_opt=SSL_CTX_get_ex_new_index(0, "opt index",
        NULL, NULL, NULL);
    index_redirect=SSL_SESSION_get_ex_new_index(0, "redirect index",
        NULL, NULL, NULL);
    index_addr=SSL_SESSION_get_ex_new_index(0, "addr index",
        NULL, NULL, cb_free);
    if(index_cli<0 || index_opt<0 || index_redirect<0 || index_addr<0) {
        s_log(LOG_ERR, "Application specific data initialization failed");
        return 1;
    }
#ifndef OPENSSL_NO_ENGINE
    ENGINE_load_builtin_engines();
#endif
#ifndef OPENSSL_NO_DH
    dh_params=get_dh2048();
    if(!dh_params) {
        s_log(LOG_ERR, "Failed to get default DH parameters");
        return 1;
    }
#endif /* OPENSSL_NO_DH */
    return 0;
}
开发者ID:NickolasLapp,项目名称:stunnel_local,代码行数:27,代码来源:ssl.c

示例4: SSL_load_error_strings

SSL_CTX *ssl_init() {
    SSL_CTX *ctx = NULL;

    SSL_load_error_strings();
    SSL_library_init();
    OpenSSL_add_all_algorithms();
    ssl_data_index = SSL_get_ex_new_index(0,0,0,0,0);

    if ((locks = calloc(CRYPTO_num_locks(), sizeof(pthread_mutex_t)))) {
        for (int i = 0; i < CRYPTO_num_locks(); i++) {
            pthread_mutex_init(&locks[i], NULL);
        }

        CRYPTO_set_locking_callback(ssl_lock);
        CRYPTO_set_id_callback(ssl_id);

        if ((ctx = SSL_CTX_new(SSLv23_client_method()))) {
            SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
            SSL_CTX_set_verify_depth(ctx, 0);
            SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
            SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_CLIENT);
            SSL_CTX_sess_set_new_cb(ctx, new_session_callback);
            SSL_CTX_set_info_callback(ctx, ssl_info_callback);
        }
    }

    return ctx;
}
开发者ID:byronhe,项目名称:wrk,代码行数:28,代码来源:ssl.c

示例5: rb_init_ssl

int
rb_init_ssl(void)
{
	int ret = 1;
	char libratbox_data[] = "libratbox data";
	SSL_load_error_strings();
	SSL_library_init();
	libratbox_index = SSL_get_ex_new_index(0, libratbox_data, NULL, NULL, NULL);
	ssl_server_ctx = SSL_CTX_new(SSLv23_server_method());
	if(ssl_server_ctx == NULL)
	{
		rb_lib_log("rb_init_openssl: Unable to initialize OpenSSL server context: %s",
			   get_ssl_error(ERR_get_error()));
		ret = 0;
	}
	/* Disable SSLv2, make the client use our settings */
	SSL_CTX_set_options(ssl_server_ctx, SSL_OP_NO_SSLv2 | SSL_OP_CIPHER_SERVER_PREFERENCE);
	SSL_CTX_set_verify(ssl_server_ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, verify_accept_all_cb);

	ssl_client_ctx = SSL_CTX_new(TLSv1_client_method());

	if(ssl_client_ctx == NULL)
	{
		rb_lib_log("rb_init_openssl: Unable to initialize OpenSSL client context: %s",
			   get_ssl_error(ERR_get_error()));
		ret = 0;
	}
	return ret;
}
开发者ID:Macs,项目名称:NeoIRCd,代码行数:29,代码来源:openssl.c

示例6: init_openssl

static void
init_openssl(struct module *module)
{
	unsigned char f_randfile[PATH_MAX];

	/* In a nutshell, on OS's without a /dev/urandom, the OpenSSL library
	 * cannot initialize the PRNG and so every attempt to use SSL fails.
	 * It's actually an OpenSSL FAQ, and according to them, it's up to the
	 * application coders to seed the RNG. -- William Yodlowsky */
	RAND_file_name(f_randfile, sizeof(f_randfile));
#ifdef HAVE_RAND_EGD
	if (RAND_egd(f_randfile) < 0) {
		/* Not an EGD, so read and write to it */
#endif
		if (RAND_load_file(f_randfile, -1))
			RAND_write_file(f_randfile);
#ifdef HAVE_RAND_EGD
	}
#endif

	SSLeay_add_ssl_algorithms();
	context = SSL_CTX_new(SSLv23_client_method());
	SSL_CTX_set_options(context, SSL_OP_ALL);
	SSL_CTX_set_default_verify_paths(context);
	socket_SSL_ex_data_idx = SSL_get_ex_new_index(0, NULL,
						      NULL,
						      socket_SSL_ex_data_dup,
						      NULL);
}
开发者ID:nabetaro,项目名称:elinks,代码行数:29,代码来源:ssl.c

示例7: tls_init_lib

void
tls_init_lib()
{
  SSL_library_init();
  SSL_load_error_strings();
  OpenSSL_add_all_algorithms ();

  mydata_index = SSL_get_ex_new_index(0, "struct session *", NULL, NULL, NULL);
  ASSERT (mydata_index >= 0);
}
开发者ID:alshalan,项目名称:Mobile-OpenVPN,代码行数:10,代码来源:ssl_openssl.c

示例8: rb_init_ssl

int
rb_init_ssl(void)
{
	int ret = 1;
	char libratbox_data[] = "libratbox data";
	SSL_load_error_strings();
	SSL_library_init();
	libratbox_index = SSL_get_ex_new_index(0, libratbox_data, NULL, NULL, NULL);

	return ret;
}
开发者ID:thors,项目名称:ircd-ratbox,代码行数:11,代码来源:openssl.c

示例9: lock

int SSLSocket::GetSSLExDataIndex() {
  if (s_ex_data_index >= 0) {
    return s_ex_data_index;
  }
  Lock lock(s_mutex);
  if (s_ex_data_index < 0) {
    s_ex_data_index = SSL_get_ex_new_index(0, (void*)"PHP stream index",
                                           NULL, NULL, NULL);
    ASSERT(s_ex_data_index >= 0);
  }
  return s_ex_data_index;
}
开发者ID:tuenti,项目名称:hiphop-php,代码行数:12,代码来源:ssl_socket.cpp

示例10: lock

int SSLSocket::GetSSLExDataIndex() {
  if (s_ex_data_index >= 0) {
    return s_ex_data_index;
  }
  Lock lock(s_mutex);
  if (s_ex_data_index < 0) {
    s_ex_data_index = SSL_get_ex_new_index(0, (void*)"PHP stream index",
                                           nullptr, nullptr, nullptr);
    assert(s_ex_data_index >= 0);
  }
  return s_ex_data_index;
}
开发者ID:524777134,项目名称:hiphop-php,代码行数:12,代码来源:ssl_socket.cpp

示例11: _get_ssl_getdns_upstream_idx

/* this should only happen once ever in the life of the library. it's
   used to associate a getdns_context_t with an SSL_CTX, to be able to
   do custom verification.
   
   see doc/HOWTO/proxy_certificates.txt as an example
*/
static int
_get_ssl_getdns_upstream_idx()
{
	static volatile int idx = -1;
	if (idx < 0) {
		CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
		if (idx < 0)
			idx = SSL_get_ex_new_index(0, "associated getdns upstream",
						   NULL,NULL,NULL);
		CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
	}
	return idx;
}
开发者ID:ATP93,项目名称:getdns,代码行数:19,代码来源:pubkey-pinning.c

示例12: rb_init_ssl

int
rb_init_ssl(void)
{
	int ret = 1;
	char libratbox_data[] = "libratbox data";
	SSL_load_error_strings();
	SSL_library_init();
	libratbox_index = SSL_get_ex_new_index(0, libratbox_data, NULL, NULL, NULL);
	ssl_server_ctx = SSL_CTX_new(SSLv23_server_method());
	if(ssl_server_ctx == NULL)
	{
		rb_lib_log("rb_init_openssl: Unable to initialize OpenSSL server context: %s",
			   get_ssl_error(ERR_get_error()));
		ret = 0;
	}
	/* Disable SSLv2, make the client use our settings */
	SSL_CTX_set_options(ssl_server_ctx, SSL_OP_NO_SSLv2 | SSL_OP_CIPHER_SERVER_PREFERENCE
#ifdef SSL_OP_SINGLE_DH_USE
			| SSL_OP_SINGLE_DH_USE
#endif
			);
	SSL_CTX_set_verify(ssl_server_ctx, SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, verify_accept_all_cb);
	SSL_CTX_set_session_id_context(ssl_server_ctx,
			(const unsigned char *)"libratbox", 9);
	SSL_CTX_set_cipher_list(ssl_server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");

	/* Set ECDHE on OpenSSL 1.00+, but make sure it's actually available because redhat are dicks
	   and bastardise their OpenSSL for stupid reasons... */
	#if (OPENSSL_VERSION_NUMBER >= 0x10000000) && defined(NID_secp384r1)
		EC_KEY *key = EC_KEY_new_by_curve_name(NID_secp384r1);
		if (key) {
			SSL_CTX_set_tmp_ecdh(ssl_server_ctx, key);
			EC_KEY_free(key);
		}
#ifdef SSL_OP_SINGLE_ECDH_USE
		SSL_CTX_set_options(ssl_server_ctx, SSL_OP_SINGLE_ECDH_USE);
#endif
	#endif

	ssl_client_ctx = SSL_CTX_new(TLSv1_client_method());

	if(ssl_client_ctx == NULL)
	{
		rb_lib_log("rb_init_openssl: Unable to initialize OpenSSL client context: %s",
			   get_ssl_error(ERR_get_error()));
		ret = 0;
	}
	return ret;
}
开发者ID:Acidburn0zzz,项目名称:charybdis,代码行数:49,代码来源:openssl.c

示例13: as_tls_check_init

void
as_tls_check_init()
{
	// Bail if we've already initialized.
	if (s_tls_inited) {
		return;
	}

	// Acquire the initialization mutex.
	pthread_mutex_lock(&s_tls_init_mutex);

	// Check the flag again, in case we lost a race.
	if (! s_tls_inited) {
#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined USE_XDR
		OpenSSL_add_all_algorithms();
		ERR_load_BIO_strings();
		ERR_load_crypto_strings();
		SSL_load_error_strings();
		SSL_library_init();

		threading_setup();

		// Install an atexit handler to cleanup.
		atexit(as_tls_cleanup);
#endif

		s_ex_name_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL);
		s_ex_ctxt_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL);
		
		as_fence_memory();
		
		s_tls_inited = true;
	}

	pthread_mutex_unlock(&s_tls_init_mutex);
}
开发者ID:aerospike,项目名称:aerospike-client-c,代码行数:36,代码来源:as_tls.c

示例14: tls_bootstrap

static int tls_bootstrap (int majorid, int minorid, void *serverarg, void *clientarg)
{
    char indexname[] = "_netsnmp_verify_info";

    /* don't do this more than once */
    if (have_done_bootstrap)
        return 0;
    have_done_bootstrap = 1;

    netsnmp_certs_load ();

    openssl_local_index = SSL_get_ex_new_index (0, indexname, NULL, NULL, NULL);

    return 0;
}
开发者ID:274914765,项目名称:C,代码行数:15,代码来源:snmpTLSBaseDomain.c

示例15: modssl_init_app_data2_idx

void modssl_init_app_data2_idx(void)
{
    int i;

    if (app_data2_idx > -1) {
        return;
    }

    /* we _do_ need to call this twice */
    for (i = 0; i <= 1; i++) {
        app_data2_idx =
            SSL_get_ex_new_index(0,
                                 "Second Application Data for SSL",
                                 NULL, NULL, NULL);
    }
}
开发者ID:pexip,项目名称:os-apache2,代码行数:16,代码来源:ssl_util_ssl.c


注:本文中的SSL_get_ex_new_index函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。