/** @file\r
X.509 Certificate Handler Wrapper Implementation over OpenSSL.\r
\r
-Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
@param ... A list of DER-encoded single certificate data followed\r
by certificate size. A NULL terminates the list. The\r
pairs are the arguments to X509ConstructCertificate().\r
- \r
+\r
@retval TRUE The X509 stack construction succeeded.\r
@retval FALSE The construction operation failed.\r
\r
EFIAPI\r
X509ConstructCertificateStack (\r
IN OUT UINT8 **X509Stack,\r
- ... \r
+ ...\r
)\r
{\r
UINT8 *Cert;\r
X509Free (\r
IN VOID *X509Cert\r
)\r
-{ \r
+{\r
//\r
// Check input parameters.\r
//\r
if (X509Cert == NULL) {\r
return;\r
}\r
- \r
+\r
//\r
// Free OpenSSL X509 object.\r
//\r
if (X509Stack == NULL) {\r
return;\r
}\r
- \r
+\r
//\r
// Free OpenSSL X509 stack object.\r
//\r
BOOLEAN Status;\r
EVP_PKEY *Pkey;\r
X509 *X509Cert;\r
- \r
+\r
//\r
// Check input parameters.\r
//\r
// Retrieve and check EVP_PKEY data from X509 Certificate.\r
//\r
Pkey = X509_get_pubkey (X509Cert);\r
- if ((Pkey == NULL) || (Pkey->type != EVP_PKEY_RSA)) {\r
+ if ((Pkey == NULL) || (EVP_PKEY_id (Pkey) != EVP_PKEY_RSA)) {\r
goto _Exit;\r
}\r
\r
//\r
// Duplicate RSA Context from the retrieved EVP_PKEY.\r
//\r
- if ((*RsaContext = RSAPublicKey_dup (Pkey->pkey.rsa)) != NULL) {\r
+ if ((*RsaContext = RSAPublicKey_dup (EVP_PKEY_get0_RSA (Pkey))) != NULL) {\r
Status = TRUE;\r
}\r
\r
\r
if (Pkey != NULL) {\r
EVP_PKEY_free (Pkey);\r
- } \r
+ }\r
\r
return Status;\r
}\r
X509 *X509Cert;\r
X509 *X509CACert;\r
X509_STORE *CertStore;\r
- X509_STORE_CTX CertCtx;\r
- \r
+ X509_STORE_CTX *CertCtx;\r
+\r
//\r
// Check input parameters.\r
//\r
X509Cert = NULL;\r
X509CACert = NULL;\r
CertStore = NULL;\r
+ CertCtx = NULL;\r
\r
//\r
// Register & Initialize necessary digest algorithms for certificate verification.\r
goto _Exit;\r
}\r
\r
+ //\r
+ // Allow partial certificate chains, terminated by a non-self-signed but\r
+ // still trusted intermediate certificate. Also disable time checks.\r
+ //\r
+ X509_STORE_set_flags (CertStore,\r
+ X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_NO_CHECK_TIME);\r
+\r
//\r
// Set up X509_STORE_CTX for the subsequent verification operation.\r
//\r
- if (!X509_STORE_CTX_init (&CertCtx, CertStore, X509Cert, NULL)) {\r
+ CertCtx = X509_STORE_CTX_new ();\r
+ if (CertCtx == NULL) {\r
+ goto _Exit;\r
+ }\r
+ if (!X509_STORE_CTX_init (CertCtx, CertStore, X509Cert, NULL)) {\r
goto _Exit;\r
}\r
\r
//\r
// X509 Certificate Verification.\r
//\r
- Status = (BOOLEAN) X509_verify_cert (&CertCtx);\r
- X509_STORE_CTX_cleanup (&CertCtx);\r
+ Status = (BOOLEAN) X509_verify_cert (CertCtx);\r
+ X509_STORE_CTX_cleanup (CertCtx);\r
\r
_Exit:\r
//\r
if (CertStore != NULL) {\r
X509_STORE_free (CertStore);\r
}\r
- \r
+\r
+ X509_STORE_CTX_free (CertCtx);\r
+\r
return Status;\r
}\r
\r
}\r
\r
*TBSCertSize = Length + (Temp - *TBSCert);\r
- \r
+\r
return TRUE;\r
}\r