OSSL_STORE_error() returns true at EOF when no error occurred, leading to "error:success"
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 30.8k
- Forks
- 11.5k
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
In the code below, CA certificates are read from a PEM file. At the end of the read, OSSL_STORE_load() returns NULL as expected, but in the code that follows, OSSL_STORE_error() returns true.
This leads to the following being logged:
failed: unable to create new TLS context: 0 (Success)
OSSL_STORE_error() should only return true of an error actually occurred - EOF is not an error.
while ((info = OSSL_STORE_load( sctx ))) {
switch (OSSL_STORE_INFO_get_type( info )) {
case OSSL_STORE_INFO_CERT:
X509 *cert = OSSL_STORE_INFO_get0_CERT( info );
X509_STORE *store = SSL_CTX_get_cert_store( ctx );
if ( !X509_STORE_add_cert( store, cert ) ) {
Debug1( LDAP_DEBUG_ANY,
"TLS: could not use certificate from uri `%s'.\n",
lo->ldo_tls_cacerturis[i] );
tlso_report_error( errmsg );
OSSL_STORE_close( sctx );
return -1;
}
if ( is_server ) {
STACK_OF(X509_NAME) *ca_list = SSL_CTX_get_client_CA_list( ctx );
if ( ca_list ) {
X509_NAME *xn = X509_get_subject_name( cert );
if ( xn )
xn = X509_NAME_dup( xn );
if ( xn )
sk_X509_NAME_push( ca_list, xn );
}
}
break;
default:
/* ignore other types */
break;
}
OSSL_STORE_INFO_free( info );
}
if (OSSL_STORE_error(sctx)) {
Debug1( LDAP_DEBUG_ANY,
"TLS: could not load from uri `%s'.\n",
lo->ldo_tls_uris[i] );
tlso_report_error( errmsg );
OSSL_STORE_close( sctx );
return -1;
}
OSSL_STORE_close( sctx );
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The reported entry points are OSSL_STORE_load() and OSSL_STORE_error(); start by tracing their EOF handling and locating the existing OSSL_STORE tests. Reproduce the PEM read shown in the issue, then verify that normal EOF is not reported as an error while genuine load failures still are.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100