summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-06-06 09:04:51 +0000
committerRoger Dingledine <arma@torproject.org>2006-06-06 09:04:51 +0000
commit8b40dda676182c2a55d1cd28a0e1a73582f76834 (patch)
tree632904c88ec8fa2ab766762dbc37c38097c48190
parentc9be59dfdc584b0205ea529620cb5ee71b93e422 (diff)
downloadtor-8b40dda676182c2a55d1cd28a0e1a73582f76834.tar.gz
tor-8b40dda676182c2a55d1cd28a0e1a73582f76834.zip
backport the part where we stop crying wolf about
tor_tls_get_peer_cert_nickname() warns. svn:r6555
-rw-r--r--src/common/tortls.c20
-rw-r--r--src/common/tortls.h3
-rw-r--r--src/or/connection_or.c6
3 files changed, 17 insertions, 12 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 2acbcbb57d..4401185c59 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -648,7 +648,8 @@ tor_tls_peer_has_cert(tor_tls_t *tls)
* NUL-terminate. Return 0 on success, -1 on failure.
*/
int
-tor_tls_get_peer_cert_nickname(tor_tls_t *tls, char *buf, size_t buflen)
+tor_tls_get_peer_cert_nickname(int severity, tor_tls_t *tls,
+ char *buf, size_t buflen)
{
X509 *cert = NULL;
X509_NAME *name = NULL;
@@ -657,11 +658,11 @@ tor_tls_get_peer_cert_nickname(tor_tls_t *tls, char *buf, size_t buflen)
int r = -1;
if (!(cert = SSL_get_peer_certificate(tls->ssl))) {
- log_warn(LD_PROTOCOL, "Peer has no certificate");
+ log_fn(severity, LD_PROTOCOL, "Peer has no certificate");
goto error;
}
if (!(name = X509_get_subject_name(cert))) {
- log_warn(LD_PROTOCOL, "Peer certificate has no subject name");
+ log_fn(severity, LD_PROTOCOL, "Peer certificate has no subject name");
goto error;
}
if ((nid = OBJ_txt2nid("commonName")) == NID_undef)
@@ -671,12 +672,13 @@ tor_tls_get_peer_cert_nickname(tor_tls_t *tls, char *buf, size_t buflen)
if (lenout == -1)
goto error;
if (((int)strspn(buf, LEGAL_NICKNAME_CHARACTERS)) < lenout) {
- log_warn(LD_PROTOCOL,
- "Peer certificate nickname %s has illegal characters.",
- escaped(buf));
+ log_fn(severity, LD_PROTOCOL,
+ "Peer certificate nickname %s has illegal characters.",
+ escaped(buf));
if (strchr(buf, '.'))
- log_warn(LD_PROTOCOL, " (Maybe it is not really running Tor at its "
- "advertised OR port.)");
+ log_fn(severity, LD_PROTOCOL,
+ " (Maybe it is not really running Tor at its "
+ "advertised OR port.)");
goto error;
}
@@ -686,7 +688,7 @@ tor_tls_get_peer_cert_nickname(tor_tls_t *tls, char *buf, size_t buflen)
if (cert)
X509_free(cert);
- tls_log_errors(LOG_WARN, "getting peer certificate nickname");
+ tls_log_errors(severity, "getting peer certificate nickname");
return r;
}
diff --git a/src/common/tortls.h b/src/common/tortls.h
index 9add9c7cea..82a64cb97a 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -32,7 +32,8 @@ tor_tls_t *tor_tls_new(int sock, int is_server, int use_no_cert);
int tor_tls_is_server(tor_tls_t *tls);
void tor_tls_free(tor_tls_t *tls);
int tor_tls_peer_has_cert(tor_tls_t *tls);
-int tor_tls_get_peer_cert_nickname(tor_tls_t *tls, char *buf, size_t buflen);
+int tor_tls_get_peer_cert_nickname(int severity, tor_tls_t *tls,
+ char *buf, size_t buflen);
int tor_tls_verify(int severity, tor_tls_t *tls, crypto_pk_env_t **identity);
int tor_tls_check_lifetime(tor_tls_t *tls, int tolerance);
int tor_tls_read(tor_tls_t *tls, char *cp, size_t len);
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 7fd717717f..946cefbb29 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -581,11 +581,13 @@ connection_or_check_valid_handshake(connection_t *conn, char *digest_rcvd)
check_no_tls_errors();
if (! tor_tls_peer_has_cert(conn->tls)) {
- log_info(LD_PROTOCOL,"Peer didn't send a cert! Closing.");
+ log_info(LD_PROTOCOL,"Peer (%s:%d) didn't send a cert! Closing.",
+ conn->address, conn->port);
return -1;
}
check_no_tls_errors();
- if (tor_tls_get_peer_cert_nickname(conn->tls, nickname, sizeof(nickname))) {
+ if (tor_tls_get_peer_cert_nickname(severity, conn->tls, nickname,
+ sizeof(nickname))) {
log_fn(severity,LD_PROTOCOL,"Other side (%s:%d) has a cert without a "
"valid nickname. Closing.",
conn->address, conn->port);