about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-01-10 17:19:42 +0000
committerMarco Peereboom <marco@conformal.com>2011-01-10 17:19:42 +0000
commitb6cb1eb34f955969eaa776ae598b77b59165aafd (patch)
tree0ff17c26678a58ce8031290d66d5f2c19c8f6c2a
parentb4199578b7d62b08f233036c6b0a3ce1cfb34372 (diff)
downloadxombrero-b6cb1eb34f955969eaa776ae598b77b59165aafd.tar.gz
fix the cert save issue for real
-rw-r--r--xxxterm.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 57e0a0d..f37033a 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -2205,8 +2205,8 @@ start_tls(int s, gnutls_session_t *gs, gnutls_certificate_credentials_t *xc)
 	if (gs == NULL || xc == NULL)
 		goto done;
 
-	bzero(&xcred, sizeof xcred);
-	bzero(&gsession, sizeof gsession);
+	*gs = NULL;
+	*xc = NULL;
 
 	gnutls_certificate_allocate_credentials(&xcred);
 	gnutls_certificate_set_x509_trust_file(xcred, ssl_ca_file,
@@ -2216,16 +2216,18 @@ start_tls(int s, gnutls_session_t *gs, gnutls_certificate_credentials_t *xc)
 	gnutls_credentials_set(gsession, GNUTLS_CRD_CERTIFICATE, xcred);
 	gnutls_transport_set_ptr(gsession, (gnutls_transport_ptr_t)(long)s);
 	if ((rv = gnutls_handshake(gsession)) < 0) {
-		warnx("gnutls_handshake failed %d", rv);
-		gnutls_certificate_free_credentials(xcred);
+		warnx("gnutls_handshake failed %d fatal %d %s",
+		    rv,
+		    gnutls_error_is_fatal(rv),
+		    gnutls_strerror_name(rv));
+		stop_tls(gsession, xcred);
 		goto done;
 	}
 
 	gnutls_credentials_type_t cred;
 	cred = gnutls_auth_get_type(gsession);
 	if (cred != GNUTLS_CRD_CERTIFICATE) {
-		gnutls_deinit(gsession);
-		gnutls_certificate_free_credentials(xcred);
+		stop_tls(gsession, xcred);
 		goto done;
 	}