Browse Source

Allow exception for weak certificate algorithms

The browsers let you add an exception for this case, so we should as
well.
pull/1643/head
Pierre Ossman 11 months ago
parent
commit
af3dae278c
1 changed files with 43 additions and 3 deletions
  1. 43
    3
      common/rfb/CSecurityTLS.cxx

+ 43
- 3
common/rfb/CSecurityTLS.cxx View File

GNUTLS_CERT_SIGNER_NOT_FOUND | GNUTLS_CERT_SIGNER_NOT_FOUND |
GNUTLS_CERT_SIGNER_NOT_CA | GNUTLS_CERT_SIGNER_NOT_CA |
GNUTLS_CERT_NOT_ACTIVATED | GNUTLS_CERT_NOT_ACTIVATED |
GNUTLS_CERT_EXPIRED;
GNUTLS_CERT_EXPIRED |
GNUTLS_CERT_INSECURE_ALGORITHM;
unsigned int status; unsigned int status;
const gnutls_datum_t *cert_list; const gnutls_datum_t *cert_list;
unsigned int cert_list_size = 0; unsigned int cert_list_size = 0;
vlog.debug("server certificate has not yet been activated"); vlog.debug("server certificate has not yet been activated");
if (status & GNUTLS_CERT_EXPIRED) if (status & GNUTLS_CERT_EXPIRED)
vlog.debug("server certificate has expired"); vlog.debug("server certificate has expired");

if (status & GNUTLS_CERT_INSECURE_ALGORITHM) if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
throw AuthFailureException("The server certificate uses an insecure algorithm");
vlog.debug("server certificate uses an insecure algorithm");


if ((status & (~allowed_errors)) != 0) { if ((status & (~allowed_errors)) != 0) {
/* No other errors are allowed */ /* No other errors are allowed */
status &= ~GNUTLS_CERT_EXPIRED; status &= ~GNUTLS_CERT_EXPIRED;
} }


if (status & GNUTLS_CERT_INSECURE_ALGORITHM) {
text = format("This certificate uses an insecure algorithm:\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,
"Insecure certificate algorithm",
text.c_str()))
throw AuthFailureException("Insecure certificate algorithm");

status &= ~GNUTLS_CERT_INSECURE_ALGORITHM;
}

if (status != 0) { if (status != 0) {
vlog.error("Unhandled certificate problems: 0x%x", status); vlog.error("Unhandled certificate problems: 0x%x", status);
throw AuthFailureException("Unhandled certificate problems"); throw AuthFailureException("Unhandled certificate problems");
status &= ~GNUTLS_CERT_EXPIRED; status &= ~GNUTLS_CERT_EXPIRED;
} }


if (status & GNUTLS_CERT_INSECURE_ALGORITHM) {
text = format("This host is previously known with a different "
"certificate, and the new certificate uses an "
"insecure algorithm:\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_INSECURE_ALGORITHM;
}

if (status != 0) { if (status != 0) {
vlog.error("Unhandled certificate problems: 0x%x", status); vlog.error("Unhandled certificate problems: 0x%x", status);
throw AuthFailureException("Unhandled certificate problems"); throw AuthFailureException("Unhandled certificate problems");

Loading…
Cancel
Save