diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-06-01 08:55:54 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-06-05 15:27:33 -0400 |
commit | 39b7e89c28efda628d57640302276b7f04b2c0de (patch) | |
tree | b382c12c6e945696d7a1fb243109d7769e8b9f41 /src | |
parent | 50facb40bb42e070b858ca052edccd0f3a5b83b5 (diff) | |
download | tor-39b7e89c28efda628d57640302276b7f04b2c0de.tar.gz tor-39b7e89c28efda628d57640302276b7f04b2c0de.zip |
Test prerequisites: function to dup a cert, make get_own_cert mockable.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/tortls.c | 13 | ||||
-rw-r--r-- | src/common/tortls.h | 3 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c index 055b4686e5..1661b7ef53 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -677,6 +677,15 @@ MOCK_IMPL(STATIC tor_x509_cert_t *, return cert; } +/** Return a new copy of <b>cert</b>. */ +tor_x509_cert_t * +tor_x509_cert_dup(const tor_x509_cert_t *cert) +{ + tor_assert(cert); + X509 *x509 = cert->cert; + return tor_x509_cert_new(X509_dup(x509)); +} + /** Read a DER-encoded X509 cert, of length exactly <b>certificate_len</b>, * from a <b>certificate</b>. Return a newly allocated tor_x509_cert_t on * success and NULL on failure. */ @@ -2023,8 +2032,8 @@ tor_tls_get_peer_cert,(tor_tls_t *tls)) /** Return the cerficate we used on the connection, or NULL if somehow * we didn't use one. */ -tor_x509_cert_t * -tor_tls_get_own_cert(tor_tls_t *tls) +MOCK_IMPL(tor_x509_cert_t *, +tor_tls_get_own_cert,(tor_tls_t *tls)) { X509 *cert = SSL_get_certificate(tls->ssl); tls_log_errors(tls, LOG_WARN, LD_HANDSHAKE, diff --git a/src/common/tortls.h b/src/common/tortls.h index ae11b7ab60..f018c45c82 100644 --- a/src/common/tortls.h +++ b/src/common/tortls.h @@ -197,8 +197,9 @@ void tor_tls_set_renegotiate_callback(tor_tls_t *tls, int tor_tls_is_server(tor_tls_t *tls); void tor_tls_free(tor_tls_t *tls); int tor_tls_peer_has_cert(tor_tls_t *tls); +tor_x509_cert_t *tor_x509_cert_dup(const tor_x509_cert_t *cert); MOCK_DECL(tor_x509_cert_t *,tor_tls_get_peer_cert,(tor_tls_t *tls)); -tor_x509_cert_t *tor_tls_get_own_cert(tor_tls_t *tls); +MOCK_DECL(tor_x509_cert_t *,tor_tls_get_own_cert,(tor_tls_t *tls)); int tor_tls_verify(int severity, tor_tls_t *tls, crypto_pk_t **identity); int tor_tls_check_lifetime(int severity, tor_tls_t *tls, int past_tolerance, |