aboutsummaryrefslogtreecommitdiff
path: root/include/salticidae/crypto.h
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-06-20 19:17:11 -0400
committerDeterminant <ted.sybil@gmail.com>2019-06-20 19:17:11 -0400
commit65f7c078663da387fd2cee8ab401c7ef66081138 (patch)
tree121e0249651e7caa3dcbd09df639879af5dd46c9 /include/salticidae/crypto.h
parent4f41e23016dc316334e7d6cc8765bdf334b96f3e (diff)
add TLS benchmark
Diffstat (limited to 'include/salticidae/crypto.h')
-rw-r--r--include/salticidae/crypto.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/include/salticidae/crypto.h b/include/salticidae/crypto.h
index 1d20b22..bcfd9dc 100644
--- a/include/salticidae/crypto.h
+++ b/include/salticidae/crypto.h
@@ -128,6 +128,10 @@ static inline int _tls_pem_with_passwd(char *buf, int size, int, void *) {
return _size - 1;
}
+static int _skip_CA_check(int, X509_STORE_CTX *) {
+ return 1;
+}
+
class PKey {
EVP_PKEY *key;
friend class TLSContext;
@@ -271,6 +275,11 @@ class TLSContext {
throw SalticidaeError(SALTI_ERROR_TLS_LOAD_KEY);
}
+ void set_verify(bool skip_ca_check = true, SSL_verify_cb verify_callback = nullptr) {
+ SSL_CTX_set_verify(ctx,
+ SSL_VERIFY_PEER, skip_ca_check ? _skip_CA_check : verify_callback);
+ }
+
bool check_privkey() {
return SSL_CTX_check_private_key(ctx) > 0;
}
@@ -329,13 +338,9 @@ class TLS {
return SSL_get_error(ssl, ret);
}
- ~TLS() {
- if (ssl)
- {
- SSL_shutdown(ssl);
- SSL_free(ssl);
- }
- }
+ void shutdown() { SSL_shutdown(ssl); }
+
+ ~TLS() { if (ssl) SSL_free(ssl); }
};
}