Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Supports full chain certificate #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions COpenSSL/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,7 @@ int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);
int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);
/* PEM type */
int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
int SSL_CTX_use_certificate_add_chain(SSL_CTX *ctx, X509 *ca, int idx);
STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);
int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs,
const char *file);
Expand Down
24 changes: 24 additions & 0 deletions COpenSSL/ssl_.c
Original file line number Diff line number Diff line change
Expand Up @@ -9844,6 +9844,7 @@ int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type)
BIO_free(in);
return (ret);
}

#endif

int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len,
Expand Down Expand Up @@ -10108,6 +10109,29 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file)
BIO_free(in);
return (ret);
}

int SSL_CTX_use_certificate_add_chain(SSL_CTX *ctx, X509 *ca, int idx)
{
ERR_clear_error();
int ret = 1;
if (idx == 1) {
SSL_CTX_clear_chain_certs(ctx);
}

long r;
unsigned long err;

r = SSL_CTX_add0_chain_cert(ctx, ca);

err = ERR_peek_last_error();
if (ERR_GET_LIB(err) == ERR_LIB_PEM
&& ERR_GET_REASON(err) == PEM_R_NO_START_LINE)
ERR_clear_error();
else
ret = 0; /* some real error */

return (ret);
}
#endif

#ifndef OPENSSL_NO_TLSEXT
Expand Down