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

Function modssl_load_keypair_engine

modules/ssl/ssl_engine_pphrase.c:845–931  ·  view source on GitHub ↗

Tries to load the key and optionally certificate via the ENGINE * API. Returns APR_ENOTIMPL if an ENGINE could not be identified * loaded from the key name. */

Source from the content-addressed store, hash-verified

843 * API. Returns APR_ENOTIMPL if an ENGINE could not be identified
844 * loaded from the key name. */
845static apr_status_t modssl_load_keypair_engine(server_rec *s, apr_pool_t *pconf,
846 apr_pool_t *ptemp,
847 const char *vhostid,
848 const char *certid,
849 const char *keyid,
850 X509 **pubkey,
851 EVP_PKEY **privkey)
852{
853 const char *c, *scheme;
854 ENGINE *e;
855 UI_METHOD *ui_method = get_passphrase_ui(ptemp);
856 pphrase_cb_arg_t ppcb;
857
858 memset(&ppcb, 0, sizeof ppcb);
859 ppcb.s = s;
860 ppcb.p = ptemp;
861 ppcb.bPassPhraseDialogOnce = TRUE;
862 ppcb.key_id = vhostid;
863 ppcb.pkey_file = keyid;
864
865 c = ap_strchr_c(keyid, ':');
866 if (!c || c == keyid) {
867 ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, APLOGNO(10131)
868 "Init: Unrecognized private key identifier `%s'",
869 keyid);
870 return APR_ENOTIMPL;
871 }
872
873 scheme = apr_pstrmemdup(ptemp, keyid, c - keyid);
874 if (!(e = ENGINE_by_id(scheme))) {
875 ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, APLOGNO(10132)
876 "Init: Failed to load engine for private key %s",
877 keyid);
878 ssl_log_ssl_error(SSLLOG_MARK, APLOG_NOTICE, s);
879 return APR_ENOTIMPL;
880 }
881
882 if (!ENGINE_init(e)) {
883 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s, APLOGNO(10149)
884 "Init: Failed to initialize engine %s for private key %s",
885 scheme, keyid);
886 ssl_log_ssl_error(SSLLOG_MARK, APLOG_EMERG, s);
887 return ssl_die(s);
888 }
889
890 ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s,
891 "Init: Initialized engine %s for private key %s",
892 scheme, keyid);
893
894 if (APLOGdebug(s)) {
895 ENGINE_ctrl_cmd_string(e, "VERBOSE", NULL, 0);
896 }
897
898 if (certid) {
899 struct {
900 const char *cert_id;
901 X509 *cert;
902 } params = { certid, NULL };

Callers 1

Calls 5

get_passphrase_uiFunction · 0.85
ap_strchr_cFunction · 0.85
ssl_log_ssl_errorFunction · 0.85
ssl_dieFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected