mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
OCSP, CRL request with "Cache-Control: no-cache" for proxy
This commit is contained in:
33
src/wolfio.c
33
src/wolfio.c
@@ -1142,9 +1142,9 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
|||||||
|
|
||||||
int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
||||||
const char* path, int pathLen, int reqSz, const char* contentType,
|
const char* path, int pathLen, int reqSz, const char* contentType,
|
||||||
byte* buf, int bufSize)
|
const char* exHdrs, byte* buf, int bufSize)
|
||||||
{
|
{
|
||||||
word32 reqTypeLen, domainNameLen, reqSzStrLen, contentTypeLen, maxLen;
|
word32 reqTypeLen, domainNameLen, reqSzStrLen, contentTypeLen, exHdrsLen, maxLen;
|
||||||
char reqSzStr[6];
|
char reqSzStr[6];
|
||||||
char* req = (char*)buf;
|
char* req = (char*)buf;
|
||||||
const char* blankStr = " ";
|
const char* blankStr = " ";
|
||||||
@@ -1152,9 +1152,10 @@ int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
|||||||
const char* hostStr = "\r\nHost: ";
|
const char* hostStr = "\r\nHost: ";
|
||||||
const char* contentLenStr = "\r\nContent-Length: ";
|
const char* contentLenStr = "\r\nContent-Length: ";
|
||||||
const char* contentTypeStr = "\r\nContent-Type: ";
|
const char* contentTypeStr = "\r\nContent-Type: ";
|
||||||
|
const char *singleCrLfStr = "\r\n";
|
||||||
const char* doubleCrLfStr = "\r\n\r\n";
|
const char* doubleCrLfStr = "\r\n\r\n";
|
||||||
word32 blankStrLen, http11StrLen, hostStrLen, contentLenStrLen,
|
word32 blankStrLen, http11StrLen, hostStrLen, contentLenStrLen,
|
||||||
contentTypeStrLen, doubleCrLfStrLen;
|
contentTypeStrLen, singleCrLfStrLen, doubleCrLfStrLen;
|
||||||
|
|
||||||
reqTypeLen = (word32)XSTRLEN(reqType);
|
reqTypeLen = (word32)XSTRLEN(reqType);
|
||||||
domainNameLen = (word32)XSTRLEN(domainName);
|
domainNameLen = (word32)XSTRLEN(domainName);
|
||||||
@@ -1166,6 +1167,15 @@ int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
|||||||
hostStrLen = (word32)XSTRLEN(hostStr);
|
hostStrLen = (word32)XSTRLEN(hostStr);
|
||||||
contentLenStrLen = (word32)XSTRLEN(contentLenStr);
|
contentLenStrLen = (word32)XSTRLEN(contentLenStr);
|
||||||
contentTypeStrLen = (word32)XSTRLEN(contentTypeStr);
|
contentTypeStrLen = (word32)XSTRLEN(contentTypeStr);
|
||||||
|
|
||||||
|
if(exHdrs){
|
||||||
|
singleCrLfStrLen = (word32)XSTRLEN(singleCrLfStr);
|
||||||
|
exHdrsLen = (word32)XSTRLEN(exHdrs);
|
||||||
|
} else {
|
||||||
|
singleCrLfStrLen = 0;
|
||||||
|
exHdrsLen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
doubleCrLfStrLen = (word32)XSTRLEN(doubleCrLfStr);
|
doubleCrLfStrLen = (word32)XSTRLEN(doubleCrLfStr);
|
||||||
|
|
||||||
/* determine max length and check it */
|
/* determine max length and check it */
|
||||||
@@ -1180,6 +1190,8 @@ int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
|||||||
reqSzStrLen +
|
reqSzStrLen +
|
||||||
contentTypeStrLen +
|
contentTypeStrLen +
|
||||||
contentTypeLen +
|
contentTypeLen +
|
||||||
|
singleCrLfStrLen +
|
||||||
|
exHdrsLen +
|
||||||
doubleCrLfStrLen +
|
doubleCrLfStrLen +
|
||||||
1 /* null term */;
|
1 /* null term */;
|
||||||
if (maxLen > (word32)bufSize)
|
if (maxLen > (word32)bufSize)
|
||||||
@@ -1211,6 +1223,15 @@ int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
|||||||
XSTRNCPY((char*)buf, contentType, bufSize);
|
XSTRNCPY((char*)buf, contentType, bufSize);
|
||||||
buf += contentTypeLen; bufSize -= contentTypeLen;
|
buf += contentTypeLen; bufSize -= contentTypeLen;
|
||||||
}
|
}
|
||||||
|
if (exHdrsLen > 0)
|
||||||
|
{
|
||||||
|
XSTRNCPY((char *)buf, singleCrLfStr, bufSize);
|
||||||
|
buf += singleCrLfStrLen;
|
||||||
|
bufSize -= singleCrLfStrLen;
|
||||||
|
XSTRNCPY((char *)buf, exHdrs, bufSize);
|
||||||
|
buf += exHdrsLen;
|
||||||
|
bufSize -= exHdrsLen;
|
||||||
|
}
|
||||||
XSTRNCPY((char*)buf, doubleCrLfStr, bufSize);
|
XSTRNCPY((char*)buf, doubleCrLfStr, bufSize);
|
||||||
buf += doubleCrLfStrLen;
|
buf += doubleCrLfStrLen;
|
||||||
|
|
||||||
@@ -1228,8 +1249,9 @@ int wolfIO_HttpBuildRequest(const char* reqType, const char* domainName,
|
|||||||
int wolfIO_HttpBuildRequestOcsp(const char* domainName, const char* path,
|
int wolfIO_HttpBuildRequestOcsp(const char* domainName, const char* path,
|
||||||
int ocspReqSz, byte* buf, int bufSize)
|
int ocspReqSz, byte* buf, int bufSize)
|
||||||
{
|
{
|
||||||
|
const char *cacheCtl = "Cache-Control: no-cache";
|
||||||
return wolfIO_HttpBuildRequest("POST", domainName, path, (int)XSTRLEN(path),
|
return wolfIO_HttpBuildRequest("POST", domainName, path, (int)XSTRLEN(path),
|
||||||
ocspReqSz, "application/ocsp-request", buf, bufSize);
|
ocspReqSz, "application/ocsp-request", cacheCtl, buf, bufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return: >0 OCSP Response Size
|
/* return: >0 OCSP Response Size
|
||||||
@@ -1341,7 +1363,8 @@ void EmbedOcspRespFree(void* ctx, byte *resp)
|
|||||||
int wolfIO_HttpBuildRequestCrl(const char* url, int urlSz,
|
int wolfIO_HttpBuildRequestCrl(const char* url, int urlSz,
|
||||||
const char* domainName, byte* buf, int bufSize)
|
const char* domainName, byte* buf, int bufSize)
|
||||||
{
|
{
|
||||||
return wolfIO_HttpBuildRequest("GET", domainName, url, urlSz, 0, "",
|
const char *cacheCtl = "Cache-Control: no-cache";
|
||||||
|
return wolfIO_HttpBuildRequest("GET", domainName, url, urlSz, cacheCtl, 0, "",
|
||||||
buf, bufSize);
|
buf, bufSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -392,7 +392,7 @@ WOLFSSL_API int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
|||||||
|
|
||||||
WOLFSSL_API int wolfIO_HttpBuildRequest(const char* reqType,
|
WOLFSSL_API int wolfIO_HttpBuildRequest(const char* reqType,
|
||||||
const char* domainName, const char* path, int pathLen, int reqSz,
|
const char* domainName, const char* path, int pathLen, int reqSz,
|
||||||
const char* contentType, unsigned char* buf, int bufSize);
|
const char* contentType, const char* exHdrs, unsigned char* buf, int bufSize);
|
||||||
WOLFSSL_API int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
WOLFSSL_API int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
||||||
unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
|
unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
|
||||||
int dynType, void* heap);
|
int dynType, void* heap);
|
||||||
|
Reference in New Issue
Block a user