Merge pull request #2466 from WarheadsSE/fix-cert-chain-validation-GH2446
libfreerdp: crypto: add certificate chain validation!
This commit is contained in:
commit
e059804706
@ -72,6 +72,7 @@ struct crypto_hmac_struct
|
||||
struct crypto_cert_struct
|
||||
{
|
||||
X509 * px509;
|
||||
STACK_OF(X509) *px509chain;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -533,7 +533,7 @@ BOOL x509_verify_certificate(CryptoCert cert, char* certificate_store_path)
|
||||
|
||||
X509_STORE_set_flags(cert_ctx, 0);
|
||||
|
||||
if (!X509_STORE_CTX_init(csc, cert_ctx, xcert, 0))
|
||||
if (!X509_STORE_CTX_init(csc, cert_ctx, xcert, cert->px509chain))
|
||||
goto end;
|
||||
|
||||
if (X509_verify_cert(csc) == 1)
|
||||
|
@ -504,6 +504,7 @@ static CryptoCert tls_get_certificate(rdpTls* tls, BOOL peer)
|
||||
{
|
||||
CryptoCert cert;
|
||||
X509* remote_cert;
|
||||
STACK_OF(X509) *chain;
|
||||
|
||||
if (peer)
|
||||
remote_cert = SSL_get_peer_certificate(tls->ssl);
|
||||
@ -524,6 +525,11 @@ static CryptoCert tls_get_certificate(rdpTls* tls, BOOL peer)
|
||||
}
|
||||
|
||||
cert->px509 = remote_cert;
|
||||
|
||||
/* Get the peer's chain. If it does not exist, we're setting NULL (clean data either way) */
|
||||
chain = SSL_get_peer_cert_chain(tls->ssl);
|
||||
cert->px509chain = chain;
|
||||
|
||||
return cert;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user