Skip to content

Commit b5dfe0d

Browse files
committed
libvncclient: tls_gnutls: use system CA files if none specified
1 parent 36413f2 commit b5dfe0d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/libvncclient/tls_gnutls.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -409,23 +409,24 @@ CreateX509CertCredential(rfbCredential *cred)
409409
gnutls_certificate_credentials_t x509_cred;
410410
int ret;
411411

412-
if (!cred->x509Credential.x509CACertFile)
413-
{
414-
rfbClientLog("No CA certificate provided.\n");
415-
return NULL;
416-
}
417-
418412
if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0)
419413
{
420414
rfbClientLog("Cannot allocate credentials: %s.\n", gnutls_strerror(ret));
421415
return NULL;
422416
}
423-
if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred,
424-
cred->x509Credential.x509CACertFile, GNUTLS_X509_FMT_PEM)) < 0)
417+
if (cred->x509Credential.x509CACertFile)
425418
{
426-
rfbClientLog("Cannot load CA credentials: %s.\n", gnutls_strerror(ret));
427-
gnutls_certificate_free_credentials (x509_cred);
428-
return NULL;
419+
if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred,
420+
cred->x509Credential.x509CACertFile, GNUTLS_X509_FMT_PEM)) < 0)
421+
{
422+
rfbClientLog("Cannot load CA credentials: %s.\n", gnutls_strerror(ret));
423+
gnutls_certificate_free_credentials (x509_cred);
424+
return NULL;
425+
}
426+
} else
427+
{
428+
int certs = gnutls_certificate_set_x509_system_trust (x509_cred);
429+
rfbClientLog("Using default paths for certificate verification, %d certs found\n", certs);
429430
}
430431
if (cred->x509Credential.x509ClientCertFile && cred->x509Credential.x509ClientKeyFile)
431432
{

0 commit comments

Comments
 (0)