Skip to content

Commit 4314369

Browse files
committed
DTLS: Improve logging
1 parent 81316b6 commit 4314369

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/netlog/netlog-dtls.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ static int dtls_write(DTLSManager *m, const char *buf, size_t count) {
2525
ERR_clear_error();
2626
r = SSL_write(m->ssl, buf, count);
2727
if (r <= 0)
28-
return log_error_errno(r, "Failed to invoke SSL_write: %s", TLS_ERROR_STRING(SSL_get_error(m->ssl, r)));
28+
return log_error_errno(r, "DTLS: Failed to invoke SSL_write: %s", TLS_ERROR_STRING(SSL_get_error(m->ssl, r)));
2929

30-
return log_debug("Successful DTLS SSL_write: %d bytes", r);
30+
return log_debug("DTLS: Successful SSL_write: %d bytes", r);
3131
}
3232

3333
int dtls_datagram_writev(DTLSManager *m, const struct iovec *iov, size_t iovcnt) {
@@ -90,61 +90,61 @@ int dtls_connect(DTLSManager *m, SocketAddress *address) {
9090

9191
fd = socket(AF_INET, SOCK_DGRAM, 0);
9292
if (fd < 0)
93-
return log_error_errno(errno, "Failed to allocate socket: %m");;
93+
return log_error_errno(errno, "DTLS: Failed to allocate socket: %m");;
9494

9595
r = sockaddr_pretty(&address->sockaddr.sa, salen, true, true, &pretty);
9696
if (r < 0)
9797
return r;
9898

9999
r = connect(fd, &address->sockaddr.sa, salen);
100100
if (r < 0 && errno != EINPROGRESS)
101-
return log_error_errno(errno, "Failed to connect to remote server='%s': %m", pretty);;
101+
return log_error_errno(errno, "DTLS: Failed to connect to remote server='%s': %m", pretty);;
102102

103103
log_debug("Connected to remote server: '%s'", pretty);
104104

105105
ctx = SSL_CTX_new(DTLS_method());
106106
if (!ctx)
107107
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
108-
"Failed to allocate memory for SSL CTX: %m");
108+
"DTLS: Failed to allocate memory for SSL CTX: %m");
109109

110110
ssl = SSL_new(ctx);
111111
if (!ssl)
112112
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
113-
"Failed to allocate memory for ssl: %s",
113+
"DTLS: Failed to allocate memory for ssl: %s",
114114
ERR_error_string(ERR_get_error(), NULL));
115115

116116
/* Create BIO from socket array! */
117117
bio = BIO_new_dgram(fd, BIO_NOCLOSE);
118118
if (!bio)
119119
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
120-
"Failed to allocate memory for bio: %m");
120+
"DTLS: Failed to allocate memory for bio: %m");
121121

122122
BIO_ctrl(bio, BIO_CTRL_DGRAM_SET_CONNECTED, 0, &address);
123123
SSL_set_bio(ssl, bio, bio);
124124
m->bio = TAKE_PTR(bio);
125125

126126
/* Cerification verification */
127127
if (m->auth_mode != OPEN_SSL_CERTIFICATE_AUTH_MODE_NONE && m->auth_mode != OPEN_SSL_CERTIFICATE_AUTH_MODE_INVALID) {
128-
log_debug("TLS: enable certificate verification");
128+
log_debug("DTLS: enable certificate verification");
129129

130130
SSL_set_ex_data(ssl, 0, m);
131131
SSL_set_ex_data(ssl, 1, address);
132132
SSL_set_verify(ssl, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, ssl_verify_certificate_validity);
133133
} else {
134-
log_debug("TLS: disable certificate verification");
134+
log_debug("DTLS: disable certificate verification");
135135
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
136136
}
137137
SSL_CTX_set_default_verify_paths(ctx);
138138

139139
r = SSL_connect(ssl);
140140
if (r <= 0)
141141
return log_error_errno(SYNTHETIC_ERRNO(ENOMEM),
142-
"Failed to SSL_connect: %s",
142+
"DTLS: Failed to SSL_connect: %s",
143143
ERR_error_string(ERR_get_error(), NULL));
144144

145145
cipher = SSL_get_current_cipher(ssl);
146146

147-
log_debug("SSL: Cipher Version: %s Name: %s", SSL_CIPHER_get_version(cipher), SSL_CIPHER_get_name(cipher));
147+
log_debug("DTLS: SSL Cipher Version: %s Name: %s", SSL_CIPHER_get_version(cipher), SSL_CIPHER_get_name(cipher));
148148
if (DEBUG_LOGGING) {
149149
_cleanup_(X509_freep) X509* cert = NULL;
150150

0 commit comments

Comments
 (0)