Index: generic/tls.c
==================================================================
--- generic/tls.c
+++ generic/tls.c
@@ -766,10 +766,12 @@
 	return TCL_ERROR;
     }
     if ((objc > 3) && Tcl_GetBooleanFromObj(interp, objv[3], &use_supported) != TCL_OK) {
 	return TCL_ERROR;
     }
+
+    ERR_clear_error();
 
     switch ((enum protocol)index) {
 	case TLS_SSL2:
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(NO_SSL2) || defined(OPENSSL_NO_SSL2)
 	    Tcl_AppendResult(interp, protocols[index], ": protocol not supported", NULL);
@@ -1536,10 +1538,11 @@
 	off |= (ENABLED(proto, TLS_PROTO_TLS1_3) ? 0 : SSL_OP_NO_TLSv1_3);
 #endif
 	break;
     }
 
+    ERR_clear_error();
     ctx = SSL_CTX_new(method);
 
     if (!ctx) {
 	return(NULL);
     }
@@ -1889,22 +1892,13 @@
 
     /* Connection info */
     statePtr = (State *)Tcl_GetChannelInstanceData(chan);
     ssl = statePtr->ssl;
     if (ssl != NULL) {
-	const char *state;
-
 	/* connection state */
-	if (SSL_is_init_finished(ssl)) {
-	    state = "established";
-	} else if (SSL_in_init(ssl)) {
-	    state = "handshake";
-	} else {
-	    state = "initializing";
-	}
 	Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj("state", -1));
-	Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj(state, -1));
+	Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj(SSL_state_string_long(ssl), -1));
 
 	/* Get server name */
 	Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj("servername", -1));
 	Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj(SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name), -1));