MCPcopy Create free account
hub / github.com/apache/httpd / modssl_read_privatekey

Function modssl_read_privatekey

modules/ssl/ssl_util_ssl.c:77–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75*/
76
77EVP_PKEY *modssl_read_privatekey(const char *filename, pem_password_cb *cb, void *s)
78{
79 EVP_PKEY *rc;
80 BIO *bioS;
81 BIO *bioF;
82
83 /* 1. try PEM (= DER+Base64+headers) */
84 if ((bioS=BIO_new_file(filename, "r")) == NULL)
85 return NULL;
86 rc = PEM_read_bio_PrivateKey(bioS, NULL, cb, s);
87 BIO_free(bioS);
88
89 if (rc == NULL) {
90 /* 2. try DER+Base64 */
91 if ((bioS = BIO_new_file(filename, "r")) == NULL)
92 return NULL;
93
94 if ((bioF = BIO_new(BIO_f_base64())) == NULL) {
95 BIO_free(bioS);
96 return NULL;
97 }
98 bioS = BIO_push(bioF, bioS);
99 rc = d2i_PrivateKey_bio(bioS, NULL);
100 BIO_free_all(bioS);
101
102 if (rc == NULL) {
103 /* 3. try plain DER */
104 if ((bioS = BIO_new_file(filename, "r")) == NULL)
105 return NULL;
106 rc = d2i_PrivateKey_bio(bioS, NULL);
107 BIO_free(bioS);
108 }
109 }
110 return rc;
111}
112
113/* _________________________________________________________________
114**

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected