/* global tls context, keep it here because nobody else needs to touch it */
static tor_tls_context *global_tls_context=NULL;
+static int tls_library_is_initialized = 0;
#define _TOR_TLS_SYSCALL -6
#define _TOR_TLS_ZERORETURN -5
}
}
+static void
+tor_tls_init() {
+ if (!tls_library_is_initialized) {
+ SSL_library_init();
+ tls_library_is_initialized = 1;
+ }
+}
+
static int always_accept_verify_cb(int preverify_ok,
X509_STORE_CTX *x509_ctx)
{
int nid;
int r;
+ tor_tls_init();
+
start_time = time(NULL);
assert(rsa);
if (!(name = X509_NAME_new()))
goto error;
- if ((nid = OBJ_txt2nid("organizationName")) != NID_undef) goto error;
+ if ((nid = OBJ_txt2nid("organizationName")) == NID_undef) goto error;
if (!(X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC,
"TOR", -1, -1, 0))) goto error;
- if ((nid = OBJ_txt2nid("commonName")) != NID_undef) goto error;
+ if ((nid = OBJ_txt2nid("commonName")) == NID_undef) goto error;
if (!(X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC,
nickname, -1, -1, 0))) goto error;
assert((certfile && rsa) || (!certfile && !rsa));
+ tor_tls_init();
+
result = tor_malloc(sizeof(tor_tls_context));
result->ctx = NULL;
#ifdef EVERYONE_HAS_AES