EST: Implement pkcs7_to_cert() with BoringSSL
This adds one more step in completing hs20-osu-client support when using BoringSSL instead of OpenSSL. EST client can now parse the cacerts file. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
8d27efa814
commit
ed2566ac9b
1 changed files with 20 additions and 4 deletions
|
@ -28,16 +28,27 @@ static int pkcs7_to_cert(struct hs20_osu_client *ctx, const u8 *pkcs7,
|
||||||
size_t len, char *pem_file, char *der_file)
|
size_t len, char *pem_file, char *der_file)
|
||||||
{
|
{
|
||||||
#ifdef OPENSSL_IS_BORINGSSL
|
#ifdef OPENSSL_IS_BORINGSSL
|
||||||
wpa_printf(MSG_ERROR,
|
CBS pkcs7_cbs;
|
||||||
"EST: pkcs7_to_cert not yet supported with BoringSSL");
|
|
||||||
return -1;
|
|
||||||
#else /* OPENSSL_IS_BORINGSSL */
|
#else /* OPENSSL_IS_BORINGSSL */
|
||||||
PKCS7 *p7 = NULL;
|
PKCS7 *p7 = NULL;
|
||||||
const unsigned char *p = pkcs7;
|
const unsigned char *p = pkcs7;
|
||||||
|
#endif /* OPENSSL_IS_BORINGSSL */
|
||||||
STACK_OF(X509) *certs;
|
STACK_OF(X509) *certs;
|
||||||
int i, num, ret = -1;
|
int i, num, ret = -1;
|
||||||
BIO *out = NULL;
|
BIO *out = NULL;
|
||||||
|
|
||||||
|
#ifdef OPENSSL_IS_BORINGSSL
|
||||||
|
certs = sk_X509_new_null();
|
||||||
|
if (!certs)
|
||||||
|
goto fail;
|
||||||
|
CBS_init(&pkcs7_cbs, pkcs7, len);
|
||||||
|
if (!PKCS7_get_certificates(certs, &pkcs7_cbs)) {
|
||||||
|
wpa_printf(MSG_INFO, "Could not parse PKCS#7 object: %s",
|
||||||
|
ERR_error_string(ERR_get_error(), NULL));
|
||||||
|
write_result(ctx, "Could not parse PKCS#7 object from EST");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
#else /* OPENSSL_IS_BORINGSSL */
|
||||||
p7 = d2i_PKCS7(NULL, &p, len);
|
p7 = d2i_PKCS7(NULL, &p, len);
|
||||||
if (p7 == NULL) {
|
if (p7 == NULL) {
|
||||||
wpa_printf(MSG_INFO, "Could not parse PKCS#7 object: %s",
|
wpa_printf(MSG_INFO, "Could not parse PKCS#7 object: %s",
|
||||||
|
@ -57,6 +68,7 @@ static int pkcs7_to_cert(struct hs20_osu_client *ctx, const u8 *pkcs7,
|
||||||
certs = NULL;
|
certs = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif /* OPENSSL_IS_BORINGSSL */
|
||||||
|
|
||||||
if (!certs || ((num = sk_X509_num(certs)) == 0)) {
|
if (!certs || ((num = sk_X509_num(certs)) == 0)) {
|
||||||
wpa_printf(MSG_INFO, "No certificates found in PKCS#7 object");
|
wpa_printf(MSG_INFO, "No certificates found in PKCS#7 object");
|
||||||
|
@ -89,12 +101,16 @@ static int pkcs7_to_cert(struct hs20_osu_client *ctx, const u8 *pkcs7,
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
#ifdef OPENSSL_IS_BORINGSSL
|
||||||
|
if (certs)
|
||||||
|
sk_X509_pop_free(certs, X509_free);
|
||||||
|
#else /* OPENSSL_IS_BORINGSSL */
|
||||||
PKCS7_free(p7);
|
PKCS7_free(p7);
|
||||||
|
#endif /* OPENSSL_IS_BORINGSSL */
|
||||||
if (out)
|
if (out)
|
||||||
BIO_free_all(out);
|
BIO_free_all(out);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif /* OPENSSL_IS_BORINGSSL */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue