mirror of
https://github.com/esp8266/Arduino.git
synced 2025-10-15 11:26:40 +03:00
* X509 State, country and location are now used for verification and display.
* SNI hostname memory is now managed by the calling application * X509 version number is checked before processing v3 extensions. git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@272 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
committed by
Ivan Grokhotkov
parent
425067abe6
commit
2213f30449
60
ssl/x509.c
60
ssl/x509.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2015, Cameron Rich
|
||||
* Copyright (c) 2007-2016, Cameron Rich
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -73,6 +73,7 @@ int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx)
|
||||
{
|
||||
int begin_tbs, end_tbs, begin_spki, end_spki;
|
||||
int ret = X509_NOT_OK, offset = 0, cert_size = 0;
|
||||
int version = 0;
|
||||
X509_CTX *x509_ctx;
|
||||
#ifdef CONFIG_SSL_CERT_VERIFICATION /* only care if doing verification */
|
||||
BI_CTX *bi_ctx;
|
||||
@@ -96,7 +97,7 @@ int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx)
|
||||
|
||||
if (cert[offset] == ASN1_EXPLICIT_TAG) /* optional version */
|
||||
{
|
||||
if (asn1_version(cert, &offset, x509_ctx))
|
||||
if ((version = asn1_version(cert, &offset, x509_ctx)) == X509_NOT_OK)
|
||||
goto end_cert;
|
||||
}
|
||||
|
||||
@@ -122,7 +123,6 @@ int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx)
|
||||
goto end_cert;
|
||||
end_spki = offset;
|
||||
|
||||
|
||||
x509_ctx->fingerprint = malloc(SHA1_SIZE);
|
||||
SHA1_CTX sha_fp_ctx;
|
||||
SHA1_Init(&sha_fp_ctx);
|
||||
@@ -197,7 +197,7 @@ int x509_new(const uint8_t *cert, int *len, X509_CTX **ctx)
|
||||
break;
|
||||
}
|
||||
|
||||
if (cert[offset] == ASN1_V3_DATA)
|
||||
if (version == 2 && cert[offset] == ASN1_V3_DATA)
|
||||
{
|
||||
int suboffset;
|
||||
|
||||
@@ -518,9 +518,29 @@ void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx)
|
||||
printf("%s\n", cert->cert_dn[X509_ORGANIZATION] ?
|
||||
cert->cert_dn[X509_ORGANIZATION] : not_part_of_cert);
|
||||
|
||||
printf("Organizational Unit (OU):\t");
|
||||
printf("%s\n", cert->cert_dn[X509_ORGANIZATIONAL_UNIT] ?
|
||||
cert->cert_dn[X509_ORGANIZATIONAL_UNIT] : not_part_of_cert);
|
||||
if (cert->cert_dn[X509_ORGANIZATIONAL_UNIT])
|
||||
{
|
||||
printf("Organizational Unit (OU):\t");
|
||||
printf("%s\n", cert->cert_dn[X509_ORGANIZATIONAL_UNIT]);
|
||||
}
|
||||
|
||||
if (cert->cert_dn[X509_LOCATION])
|
||||
{
|
||||
printf("Location (L):\t\t\t");
|
||||
printf("%s\n", cert->cert_dn[X509_LOCATION]);
|
||||
}
|
||||
|
||||
if (cert->cert_dn[X509_COUNTRY])
|
||||
{
|
||||
printf("Country (C):\t\t\t");
|
||||
printf("%s\n", cert->cert_dn[X509_COUNTRY]);
|
||||
}
|
||||
|
||||
if (cert->cert_dn[X509_STATE])
|
||||
{
|
||||
printf("State (ST):\t\t\t");
|
||||
printf("%s\n", cert->cert_dn[X509_STATE]);
|
||||
}
|
||||
|
||||
printf("=== CERTIFICATE ISSUED BY ===\n");
|
||||
printf("Common Name (CN):\t\t");
|
||||
@@ -531,9 +551,29 @@ void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx)
|
||||
printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATION] ?
|
||||
cert->ca_cert_dn[X509_ORGANIZATION] : not_part_of_cert);
|
||||
|
||||
printf("Organizational Unit (OU):\t");
|
||||
printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT] ?
|
||||
cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT] : not_part_of_cert);
|
||||
if (cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT])
|
||||
{
|
||||
printf("Organizational Unit (OU):\t");
|
||||
printf("%s\n", cert->ca_cert_dn[X509_ORGANIZATIONAL_UNIT]);
|
||||
}
|
||||
|
||||
if (cert->ca_cert_dn[X509_LOCATION])
|
||||
{
|
||||
printf("Location (L):\t\t\t");
|
||||
printf("%s\n", cert->ca_cert_dn[X509_LOCATION]);
|
||||
}
|
||||
|
||||
if (cert->ca_cert_dn[X509_COUNTRY])
|
||||
{
|
||||
printf("Country (C):\t\t\t");
|
||||
printf("%s\n", cert->ca_cert_dn[X509_COUNTRY]);
|
||||
}
|
||||
|
||||
if (cert->ca_cert_dn[X509_STATE])
|
||||
{
|
||||
printf("State (ST):\t\t\t");
|
||||
printf("%s\n", cert->ca_cert_dn[X509_STATE]);
|
||||
}
|
||||
|
||||
printf("Not Before:\t\t\t%s", ctime(&cert->not_before));
|
||||
printf("Not After:\t\t\t%s", ctime(&cert->not_after));
|
||||
|
Reference in New Issue
Block a user