forked from wolfSSL/wolfssl
handeling DER to internal of an OCSP response with no optional certificates
This commit is contained in:
@@ -33,4 +33,5 @@ EXTRA_DIST += \
|
|||||||
certs/ocsp/server5-cert.pem \
|
certs/ocsp/server5-cert.pem \
|
||||||
certs/ocsp/root-ca-key.pem \
|
certs/ocsp/root-ca-key.pem \
|
||||||
certs/ocsp/root-ca-cert.pem \
|
certs/ocsp/root-ca-cert.pem \
|
||||||
certs/ocsp/test-response.der
|
certs/ocsp/test-response.der \
|
||||||
|
certs/ocsp/test-response-nointern.der
|
||||||
|
@@ -86,6 +86,9 @@ openssl ocsp -port 22221 -ndays 1000 -index index-ca-and-intermediate-cas.txt -r
|
|||||||
PID=$!
|
PID=$!
|
||||||
|
|
||||||
openssl ocsp -issuer ./root-ca-cert.pem -cert ./intermediate1-ca-cert.pem -url http://localhost:22221/ -respout test-response.der
|
openssl ocsp -issuer ./root-ca-cert.pem -cert ./intermediate1-ca-cert.pem -url http://localhost:22221/ -respout test-response.der
|
||||||
|
openssl ocsp -issuer ./root-ca-cert.pem -cert ./intermediate1-ca-cert.pem -url http://localhost:22221/ -respout test-response-nointern.der -no_intern
|
||||||
|
# can verify with the following command
|
||||||
|
# openssl ocsp -respin test-response-nointern.der -CAfile root-ca-cert.pem -issuer intermediate1-ca-cert.pem
|
||||||
|
|
||||||
kill $PID
|
kill $PID
|
||||||
wait $PID
|
wait $PID
|
||||||
|
BIN
certs/ocsp/test-response-nointern.der
Normal file
BIN
certs/ocsp/test-response-nointern.der
Normal file
Binary file not shown.
@@ -826,6 +826,7 @@ OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
|
|||||||
OcspResponse *resp = NULL;
|
OcspResponse *resp = NULL;
|
||||||
word32 idx = 0;
|
word32 idx = 0;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -867,7 +868,10 @@ OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
|
|||||||
XMEMCPY(resp->source, *data, len);
|
XMEMCPY(resp->source, *data, len);
|
||||||
resp->maxIdx = len;
|
resp->maxIdx = len;
|
||||||
|
|
||||||
if (OcspResponseDecode(resp, NULL, NULL, 1) != 0) {
|
ret = OcspResponseDecode(resp, NULL, NULL, 1);
|
||||||
|
if (ret != 0 && ret != ASN_OCSP_CONFIRM_E) {
|
||||||
|
/* for just converting from a DER to an internal structure the CA may
|
||||||
|
* not yet be known to this function for signature verification */
|
||||||
wolfSSL_OCSP_RESPONSE_free(resp);
|
wolfSSL_OCSP_RESPONSE_free(resp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
13
tests/api.c
13
tests/api.c
@@ -1407,6 +1407,7 @@ static void test_wolfSSL_CheckOCSPResponse(void)
|
|||||||
{
|
{
|
||||||
#if defined(HAVE_OCSP) && !defined(NO_RSA) && defined(OPENSSL_ALL)
|
#if defined(HAVE_OCSP) && !defined(NO_RSA) && defined(OPENSSL_ALL)
|
||||||
const char* responseFile = "./certs/ocsp/test-response.der";
|
const char* responseFile = "./certs/ocsp/test-response.der";
|
||||||
|
const char* responseNoInternFile = "./certs/ocsp/test-response-nointern.der";
|
||||||
const char* caFile = "./certs/ocsp/root-ca-cert.pem";
|
const char* caFile = "./certs/ocsp/root-ca-cert.pem";
|
||||||
OcspResponse* res = NULL;
|
OcspResponse* res = NULL;
|
||||||
byte data[4096];
|
byte data[4096];
|
||||||
@@ -1442,6 +1443,18 @@ static void test_wolfSSL_CheckOCSPResponse(void)
|
|||||||
wolfSSL_X509_STORE_free(st);
|
wolfSSL_X509_STORE_free(st);
|
||||||
wolfSSL_X509_free(issuer);
|
wolfSSL_X509_free(issuer);
|
||||||
|
|
||||||
|
/* check loading a response with optional certs */
|
||||||
|
f = XFOPEN(responseNoInternFile, "rb");
|
||||||
|
AssertTrue(f != XBADFILE);
|
||||||
|
dataSz = (word32)XFREAD(data, 1, sizeof(data), f);
|
||||||
|
AssertIntGT(dataSz, 0);
|
||||||
|
XFCLOSE(f);
|
||||||
|
|
||||||
|
pt = data;
|
||||||
|
res = wolfSSL_d2i_OCSP_RESPONSE(NULL, &pt, dataSz);
|
||||||
|
AssertNotNull(res);
|
||||||
|
wolfSSL_OCSP_RESPONSE_free(res);
|
||||||
|
|
||||||
printf(resultFmt, passed);
|
printf(resultFmt, passed);
|
||||||
#endif /* HAVE_OCSP */
|
#endif /* HAVE_OCSP */
|
||||||
}
|
}
|
||||||
|
@@ -33441,7 +33441,9 @@ static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,
|
|||||||
#ifndef WOLFSSL_ASN_TEMPLATE
|
#ifndef WOLFSSL_ASN_TEMPLATE
|
||||||
int length;
|
int length;
|
||||||
word32 idx = *ioIndex;
|
word32 idx = *ioIndex;
|
||||||
|
#ifndef WOLFSSL_NO_OCSP_OPTIONAL_CERTS
|
||||||
word32 end_index;
|
word32 end_index;
|
||||||
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
int sigLength;
|
int sigLength;
|
||||||
|
|
||||||
@@ -33453,7 +33455,9 @@ static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,
|
|||||||
|
|
||||||
if (idx + length > size)
|
if (idx + length > size)
|
||||||
return ASN_INPUT_E;
|
return ASN_INPUT_E;
|
||||||
|
#ifndef WOLFSSL_NO_OCSP_OPTIONAL_CERTS
|
||||||
end_index = idx + length;
|
end_index = idx + length;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((ret = DecodeResponseData(source, &idx, resp, size)) < 0)
|
if ((ret = DecodeResponseData(source, &idx, resp, size)) < 0)
|
||||||
return ret; /* ASN_PARSE_E, ASN_BEFORE_DATE_E, ASN_AFTER_DATE_E */
|
return ret; /* ASN_PARSE_E, ASN_BEFORE_DATE_E, ASN_AFTER_DATE_E */
|
||||||
|
Reference in New Issue
Block a user