Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aklyuchev86 committed Jan 5, 2025
1 parent f02597d commit 0b6e98c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
3 changes: 1 addition & 2 deletions core/include/userver/server/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ namespace components {
/// task_processor | task processor to process incoming requests | -
/// backlog | max count of new connections pending acceptance | 1024
/// tls.ca | paths to TLS CAs for client authentication | -
/// tls.cert-chain | path to TLS server certificate chain | -
/// tls.cert | path to TLS server certificate | -
/// tls.cert | path to TLS server certificate chain | -
/// tls.private-key | path to TLS server certificate private key | -
/// tls.private-key-passphrase-name | passphrase name located in secdist's "passphrases" section | -
/// handler-defaults.max_url_size | max path/URL size or empty to not limit | 8192
Expand Down
11 changes: 5 additions & 6 deletions core/src/engine/io/tls_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <boost/stacktrace/stacktrace.hpp>
#include <exception>
#include <memory>
#include <ranges>

#include <fmt/format.h>
#include <openssl/bio.h>
Expand Down Expand Up @@ -514,18 +513,18 @@ TlsWrapper TlsWrapper::StartTlsServer(
LOG_INFO() << "Client SSL cert will not be verified";
}

if(cert_chain.empty())
{
if(cert_chain.empty()) {
throw TlsException(crypto::FormatSslError("Empty certificate chain provided"));
}
}

if (1 != SSL_CTX_use_certificate(ssl_ctx.get(), cert_chain.begin()->GetNative())) {
throw TlsException(crypto::FormatSslError("Failed to set up server TLS wrapper: SSL_CTX_use_certificate"));
}

if(cert_chain.size() > 1) {
for(const auto& cert : cert_chain | std::ranges::views::drop(1)) {
if (SSL_CTX_add_extra_chain_cert(ssl_ctx.get(), cert.GetNative()) <= 0) {
auto certIt = std::next(cert_chain.begin());
for (; certIt != cert_chain.end(); ++certIt) {
if (SSL_CTX_add_extra_chain_cert(ssl_ctx.get(), certIt->GetNative()) <= 0) {
throw TlsException(crypto::FormatSslError("Failed to set up server TLS wrapper: SSL_CTX_add_extra_chain_cert"));
}
}
Expand Down
6 changes: 1 addition & 5 deletions core/src/server/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ additionalProperties: false
description: path to TLS CA
cert:
type: string
description: path to TLS certificate
cert-chain:
type: string
description: path to TLS certificates chain
defaultDescription: empty string
description: path to TLS certificate chain
private-key:
type: string
description: path to TLS certificate private key
Expand Down

0 comments on commit 0b6e98c

Please sign in to comment.