mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-22 11:46:13 +00:00
Read a NUL-terminated client CA in SSLServer::PemMemory
SSLServer::PemMemory takes a length of 0 to mean a NUL-terminated string for cert_pem and key_pem, but skipped client_ca_pem when its length was 0, so a server given its client CA that way started without requiring client certificates. Read the client CA under the same rule as the other fields. An empty client CA now fails to load instead of turning the check off, and the README documents the length-0 rule.
This commit is contained in:
1 parent
67b88030e8
commit
71b5f0a1c8
3 files changed
+20
-6
No files matched your search
@@ -18824,8 +18824,10 @@ inline SSLServer::SSLServer(const PemMemory &pem) {
|
||||
last_ssl_error_ = static_cast<int>(get_error());
|
||||
free_context(ctx_);
|
||||
ctx_ = nullptr;
|
||||
} else if (pem.client_ca_pem && pem.client_ca_pem_len > 0) {
|
||||
if (!load_ca_pem(ctx_, pem.client_ca_pem, pem.client_ca_pem_len)) {
|
||||
} else if (pem.client_ca_pem) {
|
||||
auto ca_len = pem.client_ca_pem_len ? pem.client_ca_pem_len
|
||||
: strlen(pem.client_ca_pem);
|
||||
if (!load_ca_pem(ctx_, pem.client_ca_pem, ca_len)) {
|
||||
last_ssl_error_ = static_cast<int>(get_error());
|
||||
free_context(ctx_);
|
||||
ctx_ = nullptr;
|
||||
|
||||
Reference in new issue
Block a user