Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cleanup #87

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/netlog/netlog-dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ int dtls_connect(DTLSManager *m, SocketAddress *address) {
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
"Failed to allocate memory for SSL CTX: %m");

SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
SSL_CTX_set_default_verify_paths(ctx);

ssl = SSL_new(ctx);
if (!ssl)
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
Expand All @@ -136,6 +133,7 @@ int dtls_connect(DTLSManager *m, SocketAddress *address) {
log_debug("TLS: disable certificate verification");
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
}
SSL_CTX_set_default_verify_paths(ctx);

r = SSL_connect(ssl);
if (r <= 0)
Expand Down
18 changes: 3 additions & 15 deletions src/netlog/netlog-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,12 @@ int ssl_verify_certificate_validity(int s, X509_STORE_CTX *store) {
int verify_mode = SSL_get_verify_mode(ssl);
_cleanup_free_ char *pretty = NULL;
union sockaddr_union sa;
socklen_t salen;
int r;

assert(store);

switch (address->sockaddr.sa.sa_family) {
case AF_INET:
salen = sizeof(sa.in);
break;
case AF_INET6:
salen = sizeof(sa.in6);
break;
default:
return -EAFNOSUPPORT;
}

r = sockaddr_pretty(&address->sockaddr.sa, salen, true, true, &pretty);
r = sockaddr_pretty(&address->sockaddr.sa, address->sockaddr.sa.sa_family == AF_INET ?
sizeof(sa.in) : sizeof(sa.in6), true, true, &pretty);
if (r < 0)
return r;

Expand Down Expand Up @@ -222,8 +211,6 @@ int tls_connect(TLSManager *m, SocketAddress *address) {
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
"Failed to allocate memory for SSL CTX: %m");

SSL_CTX_set_default_verify_paths(ctx);

ssl = SSL_new(ctx);
if (!ssl)
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
Expand All @@ -247,6 +234,7 @@ int tls_connect(TLSManager *m, SocketAddress *address) {
log_debug("TLS: disable certificate verification");
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
}
SSL_CTX_set_default_verify_paths(ctx);

r = SSL_connect(ssl);
if (r <= 0)
Expand Down