本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}