]> source.dussan.org Git - tigervnc.git/commitdiff
Allow exception for not yet activated certificates
authorPierre Ossman <ossman@cendio.se>
Wed, 5 Jul 2023 08:36:02 +0000 (10:36 +0200)
committerPierre Ossman <ossman@cendio.se>
Wed, 5 Jul 2023 08:40:08 +0000 (10:40 +0200)
The browsers let you add an exception for this case, so we should as
well.

common/rfb/CSecurityTLS.cxx

index 735bdb6ca3cedb1e2e447e051c81732dac5c4fdb..49c3c81874491ceb357684c7e577d30cd3f2c243 100644 (file)
@@ -289,6 +289,7 @@ void CSecurityTLS::checkSession()
   const unsigned allowed_errors = GNUTLS_CERT_INVALID |
                                  GNUTLS_CERT_SIGNER_NOT_FOUND |
                                  GNUTLS_CERT_SIGNER_NOT_CA |
+                                 GNUTLS_CERT_NOT_ACTIVATED |
                                  GNUTLS_CERT_EXPIRED;
   unsigned int status;
   const gnutls_datum_t *cert_list;
@@ -314,9 +315,6 @@ void CSecurityTLS::checkSession()
   if (status & GNUTLS_CERT_REVOKED)
     throw AuthFailureException("server certificate has been revoked");
 
-  if (status & GNUTLS_CERT_NOT_ACTIVATED)
-    throw AuthFailureException("server certificate has not been activated");
-
   if (status & GNUTLS_CERT_EXPIRED) {
     vlog.debug("server certificate has expired");
     if (!msg->showMsgBox(UserMsgBox::M_YESNO, "certificate has expired",
@@ -362,6 +360,8 @@ void CSecurityTLS::checkSession()
     vlog.debug("server cert signer not found");
   if (status & GNUTLS_CERT_SIGNER_NOT_CA)
     vlog.debug("server cert signer not CA");
+  if (status & GNUTLS_CERT_NOT_ACTIVATED)
+    vlog.debug("server certificate has not yet been activated");
   if (status & GNUTLS_CERT_EXPIRED)
     vlog.debug("server certificate has expired");
 
@@ -441,6 +441,25 @@ void CSecurityTLS::checkSession()
                   GNUTLS_CERT_SIGNER_NOT_CA);
     }
 
+    if (status & GNUTLS_CERT_NOT_ACTIVATED) {
+      text = format("This certificate is not yet valid:\n"
+                    "\n"
+                    "%s\n"
+                    "\n"
+                    "Someone could be trying to impersonate the site "
+                    "and you should not continue.\n"
+                    "\n"
+                    "Do you want to make an exception for this "
+                    "server?", info.data);
+
+      if (!msg->showMsgBox(UserMsgBox::M_YESNO,
+                           "Certificate is not yet valid",
+                           text.c_str()))
+        throw AuthFailureException("Certificate is not yet valid");
+
+      status &= ~GNUTLS_CERT_NOT_ACTIVATED;
+    }
+
     if (status & GNUTLS_CERT_EXPIRED) {
       text = format("This certificate has expired:\n"
                     "\n"
@@ -495,6 +514,27 @@ void CSecurityTLS::checkSession()
                   GNUTLS_CERT_SIGNER_NOT_CA);
     }
 
+    if (status & GNUTLS_CERT_NOT_ACTIVATED) {
+      text = format("This host is previously known with a different "
+                    "certificate, and the new certificate is not yet "
+                    "valid:\n"
+                    "\n"
+                    "%s\n"
+                    "\n"
+                    "Someone could be trying to impersonate the site "
+                    "and you should not continue.\n"
+                    "\n"
+                    "Do you want to make an exception for this "
+                    "server?", info.data);
+
+      if (!msg->showMsgBox(UserMsgBox::M_YESNO,
+                           "Unexpected server certificate",
+                           text.c_str()))
+        throw AuthFailureException("Unexpected server certificate");
+
+      status &= ~GNUTLS_CERT_NOT_ACTIVATED;
+    }
+
     if (status & GNUTLS_CERT_EXPIRED) {
       text = format("This host is previously known with a different "
                     "certificate, and the new certificate has "