Skip to content

Support pkcs12 certificates in schannel #2580

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thhous-msft
Copy link
Contributor

Description

Part of #1453. Adds support for loading PKCS12 certificates in schannel

Testing

Pkcs12 tests are enabled on schannel

Documentation

No

@thhous-msft thhous-msft requested a review from a team as a code owner March 25, 2022 18:04
@thhous-msft thhous-msft marked this pull request as draft March 25, 2022 18:04
Copy link
Collaborator

@nibanks nibanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you merge main, I believe the clog change should disappear.

Comment on lines +713 to +714
HCERTSTORE CertStore,
PCCERT_CONTEXT* CertContext
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAL annotations please

Comment on lines 755 to 766
if (!CryptQueryObject(
ObjectType,
CredConfig->CertificatePkcs12->Asn1Blob,
CERT_QUERY_CONTENT_FLAG_PFX,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&MsgAndCertEncodingType,
&ContentType,
&FormatType,
&CertStore,
&Msg,
&CertContext)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!CryptQueryObject(
ObjectType,
CredConfig->CertificatePkcs12->Asn1Blob,
CERT_QUERY_CONTENT_FLAG_PFX,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&MsgAndCertEncodingType,
&ContentType,
&FormatType,
&CertStore,
&Msg,
&CertContext)) {
if (!CryptQueryObject(
ObjectType,
CredConfig->CertificatePkcs12->Asn1Blob,
CERT_QUERY_CONTENT_FLAG_PFX,
CERT_QUERY_FORMAT_FLAG_ALL,
0,
&MsgAndCertEncodingType,
&ContentType,
&FormatType,
&CertStore,
&Msg,
&CertContext)) {

goto Exit;
}

// Find the first cert with a private key. If none then take the first cert
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Find the first cert with a private key. If none then take the first cert
//
// Find the first cert with a private key. If none then take the first cert
//

}

if (CertContext == NULL) {
// TODO Maybe better error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, and plus, add an error log.

Comment on lines 978 to 979
case QUIC_CREDENTIAL_TYPE_CERTIFICATE_FILE_PROTECTED:
case QUIC_CREDENTIAL_TYPE_CERTIFICATE_PKCS12:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why these should be NOT_SUPPORTED. Is this supposed to kernel specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this chain is kernel specific. Which will never support these 2 methods, at least in the current state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait actually nevermind. I messed up here.

It loads, and partially works. It has a major leak however
@thhous-msft
Copy link
Contributor Author

This change is dependent on #2606 which requires implementing a PCKS12 writer in the selfsigned certificate generating code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants