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/libressl/ressl.c | |
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/libressl/ressl.c')
-rw-r--r-- | src/lib/libressl/ressl.c | 20 |
1 files changed, 20 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 | { |