summaryrefslogtreecommitdiff
path: root/src/ssl_certkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ssl_certkey.c')
-rw-r--r--src/ssl_certkey.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ssl_certkey.c b/src/ssl_certkey.c
new file mode 100644
index 0000000..8292cbe
--- /dev/null
+++ b/src/ssl_certkey.c
@@ -0,0 +1,19 @@
+#include "ucspissl.h"
+
+int ssl_certkey(SSL_CTX *ctx,const char *certfile,const char *keyfile,pem_password_cb *passwd_cb)
+{
+ if (!certfile) return 0;
+
+ if (SSL_CTX_use_certificate_chain_file(ctx,certfile) != 1)
+ return -1;
+
+ if (!keyfile) keyfile = certfile;
+ SSL_CTX_set_default_passwd_cb(ctx,passwd_cb);
+ if (SSL_CTX_use_PrivateKey_file(ctx,keyfile,SSL_FILETYPE_PEM) != 1)
+ return -2;
+
+ if (SSL_CTX_check_private_key(ctx) != 1)
+ return -3;
+
+ return 0;
+}