diff options
author | jsing <> | 2014-08-04 15:58:29 +0000 |
---|---|---|
committer | jsing <> | 2014-08-04 15:58:29 +0000 |
commit | 78f1b94786e7a88c2465b014db9000aae8825054 (patch) | |
tree | dc58ebd660bd30d885b18d92e575e57dfabdc2d5 /src/lib | |
parent | 5ba06d1e6f1d7f0d7316856cdf4b22225fa45513 (diff) | |
download | openbsd-78f1b94786e7a88c2465b014db9000aae8825054.tar.gz openbsd-78f1b94786e7a88c2465b014db9000aae8825054.tar.bz2 openbsd-78f1b94786e7a88c2465b014db9000aae8825054.zip |
Provide a utility function for loading a private/public keypair.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libressl/ressl.c | 20 | ||||
-rw-r--r-- | src/lib/libressl/ressl_internal.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/libressl/ressl.c b/src/lib/libressl/ressl.c index e014d3e572..44a8a19421 100644 --- a/src/lib/libressl/ressl.c +++ b/src/lib/libressl/ressl.c | |||
@@ -90,6 +90,26 @@ ressl_configure(struct ressl *ctx, struct ressl_config *config) | |||
90 | return (0); | 90 | return (0); |
91 | } | 91 | } |
92 | 92 | ||
93 | int | ||
94 | ressl_configure_keypair(struct ressl *ctx) | ||
95 | { | ||
96 | if (SSL_CTX_use_certificate_file(ctx->ssl_ctx, ctx->config->cert_file, | ||
97 | SSL_FILETYPE_PEM) != 1) { | ||
98 | ressl_set_error(ctx, "failed to load certificate"); | ||
99 | return (1); | ||
100 | } | ||
101 | if (SSL_CTX_use_PrivateKey_file(ctx->ssl_ctx, ctx->config->key_file, | ||
102 | SSL_FILETYPE_PEM) != 1) { | ||
103 | ressl_set_error(ctx, "failed to load private key"); | ||
104 | return (1); | ||
105 | } | ||
106 | if (SSL_CTX_check_private_key(ctx->ssl_ctx) != 1) { | ||
107 | ressl_set_error(ctx, "private/public key mismatch"); | ||
108 | return (1); | ||
109 | } | ||
110 | return (0); | ||
111 | } | ||
112 | |||
93 | void | 113 | void |
94 | ressl_free(struct ressl *ctx) | 114 | ressl_free(struct ressl *ctx) |
95 | { | 115 | { |
diff --git a/src/lib/libressl/ressl_internal.h b/src/lib/libressl/ressl_internal.h index c33d4cff2e..0b6a58bf2d 100644 --- a/src/lib/libressl/ressl_internal.h +++ b/src/lib/libressl/ressl_internal.h | |||
@@ -53,6 +53,7 @@ struct ressl { | |||
53 | struct ressl *ressl_new(void); | 53 | struct ressl *ressl_new(void); |
54 | 54 | ||
55 | int ressl_check_hostname(X509 *cert, const char *host); | 55 | int ressl_check_hostname(X509 *cert, const char *host); |
56 | int ressl_configure_keypair(struct ressl *ctx); | ||
56 | int ressl_host_port(const char *hostport, char **host, char **port); | 57 | int ressl_host_port(const char *hostport, char **host, char **port); |
57 | int ressl_set_error(struct ressl *ctx, char *fmt, ...); | 58 | int ressl_set_error(struct ressl *ctx, char *fmt, ...); |
58 | 59 | ||