summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2014-08-04 15:58:29 +0000
committerjsing <>2014-08-04 15:58:29 +0000
commit78f1b94786e7a88c2465b014db9000aae8825054 (patch)
treedc58ebd660bd30d885b18d92e575e57dfabdc2d5 /src/lib
parent5ba06d1e6f1d7f0d7316856cdf4b22225fa45513 (diff)
downloadopenbsd-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.c20
-rw-r--r--src/lib/libressl/ressl_internal.h1
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
93int
94ressl_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
93void 113void
94ressl_free(struct ressl *ctx) 114ressl_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 {
53struct ressl *ressl_new(void); 53struct ressl *ressl_new(void);
54 54
55int ressl_check_hostname(X509 *cert, const char *host); 55int ressl_check_hostname(X509 *cert, const char *host);
56int ressl_configure_keypair(struct ressl *ctx);
56int ressl_host_port(const char *hostport, char **host, char **port); 57int ressl_host_port(const char *hostport, char **host, char **port);
57int ressl_set_error(struct ressl *ctx, char *fmt, ...); 58int ressl_set_error(struct ressl *ctx, char *fmt, ...);
58 59