Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cups/tls-gnutls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1833,10 +1833,23 @@ _httpTLSStart(http_t *http) // I - Connection to server
// Use the CA certs...
cupsCopyString(crtfile, cacrtfile, sizeof(crtfile));
cupsCopyString(keyfile, cakeyfile, sizeof(keyfile));

have_creds = true;
}
}
else
{
// CUPS-managed self-signed certs: use them only if they have
// not expired, otherwise let the auto-create code path below
// regenerate them (Issue #1519). cupsGetCredentialsExpiration()
// expects a PEM string, not a file path, so load the cert via
// cupsCopyCredentials() first.
char *creds = cupsCopyCredentials(tls_keypath, cn);
// PEM-encoded certificate

have_creds = !access(crtfile, R_OK) && !access(keyfile, R_OK);
have_creds = creds && cupsGetCredentialsExpiration(creds) > time(NULL);
free(creds);
}
}

if (!have_creds && tls_auto_create && cn)
Expand Down
17 changes: 15 additions & 2 deletions cups/tls-openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1897,10 +1897,23 @@ _httpTLSStart(http_t *http) // I - Connection to server
// Use the CA certs...
cupsCopyString(crtfile, cacrtfile, sizeof(crtfile));
cupsCopyString(keyfile, cakeyfile, sizeof(keyfile));

have_creds = true;
}
}

have_creds = !access(crtfile, R_OK) && !access(keyfile, R_OK);
else
{
// CUPS-managed self-signed certs: use them only if they have
// not expired, otherwise let the auto-create code path below
// regenerate them (Issue #1519). cupsGetCredentialsExpiration()
// expects a PEM string, not a file path, so load the cert via
// cupsCopyCredentials() first.
char *creds = cupsCopyCredentials(tls_keypath, cn);
// PEM-encoded certificate

have_creds = creds && cupsGetCredentialsExpiration(creds) > time(NULL);
free(creds);
}
}

if (!have_creds && tls_auto_create && cn)
Expand Down