nghttpx: Use ImmutableString for private_key_file
This commit is contained in:
parent
ac81003669
commit
35ebdd35bc
|
@ -1754,7 +1754,7 @@ int parse_config(const char *opt, const char *optarg,
|
|||
LOG(ERROR) << opt << ": Couldn't read key file's passwd from " << optarg;
|
||||
return -1;
|
||||
}
|
||||
mod_config()->tls.private_key_passwd = strcopy(passwd);
|
||||
mod_config()->tls.private_key_passwd = passwd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ struct TLSConfig {
|
|||
std::string backend_sni_name;
|
||||
std::chrono::seconds session_timeout;
|
||||
ImmutableString private_key_file;
|
||||
std::unique_ptr<char[]> private_key_passwd;
|
||||
ImmutableString private_key_passwd;
|
||||
ImmutableString cert_file;
|
||||
std::unique_ptr<char[]> dh_param_file;
|
||||
std::unique_ptr<char[]> ciphers;
|
||||
|
|
|
@ -124,13 +124,13 @@ set_alpn_prefs(const std::vector<std::string> &protos) {
|
|||
namespace {
|
||||
int ssl_pem_passwd_cb(char *buf, int size, int rwflag, void *user_data) {
|
||||
auto config = static_cast<Config *>(user_data);
|
||||
int len = (int)strlen(config->tls.private_key_passwd.get());
|
||||
auto len = static_cast<int>(config->tls.private_key_passwd.size());
|
||||
if (size < len + 1) {
|
||||
LOG(ERROR) << "ssl_pem_passwd_cb: buf is too small " << size;
|
||||
return 0;
|
||||
}
|
||||
// Copy string including last '\0'.
|
||||
memcpy(buf, config->tls.private_key_passwd.get(), len + 1);
|
||||
memcpy(buf, config->tls.private_key_passwd.c_str(), len + 1);
|
||||
return len;
|
||||
}
|
||||
} // namespace
|
||||
|
@ -548,7 +548,7 @@ SSL_CTX *create_ssl_context(const char *private_key_file, const char *cert_file
|
|||
|
||||
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_AUTO_RETRY);
|
||||
SSL_CTX_set_mode(ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
|
||||
if (tlsconf.private_key_passwd) {
|
||||
if (!tlsconf.private_key_passwd.empty()) {
|
||||
SSL_CTX_set_default_passwd_cb(ssl_ctx, ssl_pem_passwd_cb);
|
||||
SSL_CTX_set_default_passwd_cb_userdata(ssl_ctx, (void *)get_config());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue