crypt32: Simplify certificate creation.
Decoding already handles signed and unsigned certs, so don't duplicate that in CertCreateCertificateContext.
This commit is contained in:
parent
38a85261cb
commit
661aecc761
|
@ -73,33 +73,15 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,
|
||||||
{
|
{
|
||||||
PCERT_CONTEXT cert = NULL;
|
PCERT_CONTEXT cert = NULL;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
PCERT_SIGNED_CONTENT_INFO signedCert = NULL;
|
|
||||||
PCERT_INFO certInfo = NULL;
|
PCERT_INFO certInfo = NULL;
|
||||||
DWORD size = 0;
|
DWORD size = 0;
|
||||||
|
|
||||||
TRACE("(%08lx, %p, %ld)\n", dwCertEncodingType, pbCertEncoded,
|
TRACE("(%08lx, %p, %ld)\n", dwCertEncodingType, pbCertEncoded,
|
||||||
cbCertEncoded);
|
cbCertEncoded);
|
||||||
|
|
||||||
/* First try to decode it as a signed cert. */
|
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CERT_TO_BE_SIGNED,
|
||||||
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CERT, pbCertEncoded,
|
pbCertEncoded, cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL,
|
||||||
cbCertEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&signedCert, &size);
|
(BYTE *)&certInfo, &size);
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
size = 0;
|
|
||||||
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CERT_TO_BE_SIGNED,
|
|
||||||
signedCert->ToBeSigned.pbData, signedCert->ToBeSigned.cbData,
|
|
||||||
CRYPT_DECODE_ALLOC_FLAG, NULL, (BYTE *)&certInfo, &size);
|
|
||||||
LocalFree(signedCert);
|
|
||||||
}
|
|
||||||
/* Failing that, try it as an unsigned cert */
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
size = 0;
|
|
||||||
ret = CryptDecodeObjectEx(dwCertEncodingType, X509_CERT_TO_BE_SIGNED,
|
|
||||||
pbCertEncoded, cbCertEncoded,
|
|
||||||
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG, NULL,
|
|
||||||
(BYTE *)&certInfo, &size);
|
|
||||||
}
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
BYTE *data = NULL;
|
BYTE *data = NULL;
|
||||||
|
|
Loading…
Reference in New Issue