diff --git a/src/wolfio.c b/src/wolfio.c index f564297c8..fca3f557c 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -933,7 +933,7 @@ static int wolfIO_HttpProcessResponseBuf(int sfd, byte **recvBuf, int* recvBufSz return 0; } -int wolfIO_HttpProcessResponse(int sfd, const char* appStr, +int wolfIO_HttpProcessResponse(int sfd, const char** appStrList, byte** respBuf, byte* httpBuf, int httpBufSz, int dynType, void* heap) { int result = 0; @@ -1016,9 +1016,21 @@ int wolfIO_HttpProcessResponse(int sfd, const char* appStr, case phr_have_length: case phr_have_type: if (XSTRNCASECMP(start, "Content-Type:", 13) == 0) { + int i; + start += 13; while (*start == ' ' && *start != '\0') start++; - if (XSTRNCASECMP(start, appStr, XSTRLEN(appStr)) != 0) { + + /* try and match against appStrList */ + i = 0; + while (appStrList[i] != NULL) { + if (XSTRNCASECMP(start, appStrList[i], + XSTRLEN(appStrList[i])) == 0) { + break; + } + i++; + } + if (appStrList[i] == NULL) { WOLFSSL_MSG("wolfIO_HttpProcessResponse appstr mismatch"); return -1; } @@ -1168,7 +1180,12 @@ int wolfIO_HttpBuildRequestOcsp(const char* domainName, const char* path, int wolfIO_HttpProcessResponseOcsp(int sfd, byte** respBuf, byte* httpBuf, int httpBufSz, void* heap) { - return wolfIO_HttpProcessResponse(sfd, "application/ocsp-response", + const char* appStrList[] = { + "application/ocsp-response", + NULL + }; + + return wolfIO_HttpProcessResponse(sfd, appStrList, respBuf, httpBuf, httpBufSz, DYNAMIC_TYPE_OCSP, heap); } @@ -1277,7 +1294,13 @@ int wolfIO_HttpProcessResponseCrl(WOLFSSL_CRL* crl, int sfd, byte* httpBuf, int result; byte *respBuf = NULL; - result = wolfIO_HttpProcessResponse(sfd, "application/pkix-crl", + const char* appStrList[] = { + "application/pkix-crl", + "application/x-pkcs7-crl", + NULL + }; + + result = wolfIO_HttpProcessResponse(sfd, appStrList, &respBuf, httpBuf, httpBufSz, DYNAMIC_TYPE_CRL, crl->heap); if (result >= 0) { result = BufferLoadCRL(crl, respBuf, result, WOLFSSL_FILETYPE_ASN1, 0); diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index a0aac6fcc..59afd029b 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -345,7 +345,7 @@ WOLFSSL_API int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags); WOLFSSL_API int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName, const char* path, int pathLen, int reqSz, const char* contentType, unsigned char* buf, int bufSize); - WOLFSSL_API int wolfIO_HttpProcessResponse(int sfd, const char* appStr, + WOLFSSL_API int wolfIO_HttpProcessResponse(int sfd, const char** appStrList, unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz, int dynType, void* heap); #endif /* HAVE_HTTP_CLIENT */