Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static int GetOcspStatus(WOLFSSL_OCSP* ocsp, OcspRequest* request,
* entry The OCSP entry for this certificate.
* returns OCSP_LOOKUP_FAIL when the response is bad and 0 otherwise.
*/
WOLFSSL_LOCAL int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz,
int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz,
WOLFSSL_BUFFER_INFO *responseBuffer, CertStatus *status,
OcspEntry *entry, OcspRequest *ocspRequest)
{
Expand Down Expand Up @@ -406,13 +406,17 @@ WOLFSSL_LOCAL int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int resp
}

/* 0 on success */
/* allow customer to override the maximum request size at build-time */
#ifndef OCSP_MAX_REQUEST_SZ
#define OCSP_MAX_REQUEST_SZ 2048
#endif
int CheckOcspRequest(WOLFSSL_OCSP* ocsp, OcspRequest* ocspRequest,
buffer* responseBuffer)
{
OcspEntry* entry = NULL;
CertStatus* status = NULL;
byte* request = NULL;
int requestSz = 2048;
int requestSz = OCSP_MAX_REQUEST_SZ;
int responseSz = 0;
byte* response = NULL;
const char* url = NULL;
Expand Down Expand Up @@ -1113,7 +1117,7 @@ WOLFSSL_OCSP_SINGLERESP* wolfSSL_OCSP_resp_get0(WOLFSSL_OCSP_BASICRESP *bs, int
return single;
}

#endif /* OPENSSL_ALL || APACHE_HTTPD */
#endif /* OPENSSL_ALL || APACHE_HTTPD || WOLFSSL_HAPROXY */

#ifdef OPENSSL_EXTRA
#ifndef NO_WOLFSSL_STUB
Expand Down
33 changes: 26 additions & 7 deletions src/wolfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,9 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
#ifdef HAVE_SOCKADDR
int ret = 0;
SOCKADDR_S addr;
int sockaddr_len = sizeof(SOCKADDR_IN);
int sockaddr_len;
/* use gethostbyname for c99 */
#if defined(HAVE_GETADDRINFO) && !defined(WOLF_C99)
#if defined(HAVE_GETADDRINFO) || defined(WOLF_C99)
ADDRINFO hints;
ADDRINFO* answer = NULL;
char strPort[6];
Expand All @@ -822,23 +822,36 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
HOSTENT *entry;
#endif
#endif
#ifdef WOLFSSL_IPV6
SOCKADDR_IN6 *sin;
#else
SOCKADDR_IN *sin;
#endif
#endif /* HAVE_SOCKADDR */

if (sockfd == NULL || ip == NULL) {
return -1;
}

#ifdef WOLFSSL_IPV6
sockaddr_len = sizeof(SOCKADDR_IN6);
#else
sockaddr_len = sizeof(SOCKADDR_IN);
#endif
XMEMSET(&addr, 0, sizeof(addr));

#ifdef WOLFIO_DEBUG
printf("TCP Connect: %s:%d\n", ip, port);
#endif

/* use gethostbyname for c99 */
#if defined(HAVE_GETADDRINFO) && !defined(WOLF_C99)
#if defined(HAVE_GETADDRINFO) || defined(WOLF_C99)
XMEMSET(&hints, 0, sizeof(hints));
#ifdef WOLFSSL_IPV6
hints.ai_family = AF_INET6;
#else
hints.ai_family = AF_UNSPEC;
#endif
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;

Expand All @@ -855,7 +868,7 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
sockaddr_len = answer->ai_addrlen;
XMEMCPY(&addr, answer->ai_addr, sockaddr_len);
freeaddrinfo(answer);
#elif defined(WOLFSSL_USE_POPEN_HOST)
#elif defined(WOLFSSL_USE_POPEN_HOST) && !defined(WOLFSSL_IPV6)
{
char host_ipaddr[4] = { 127, 0, 0, 1 };
int found = 1;
Expand Down Expand Up @@ -907,10 +920,9 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
}
if (found) {
sin = (SOCKADDR_IN *)&addr;

sin->sin_family = AF_INET;
sin->sin_port = XHTONS(port);
XMEMCPY(&sin->sin_addr.s_addr, host_ipaddr, sizeof(host_ipaddr));
XMEMCPY(&sin->sin_addr.s_addr, host_ipaddr, sizeof(host_ipaddr));
}
else {
WOLFSSL_MSG("no addr info for responder");
Expand All @@ -932,12 +944,19 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
#else
entry = gethostbyname(ip);
#endif
sin = (SOCKADDR_IN *)&addr;

if (entry) {
#ifdef WOLFSSL_IPV6
sin = (SOCKADDR_IN6 *)&addr;
sin->sin6_family = AF_INET6;
sin->sin6_port = XHTONS(port);
XMEMCPY(&sin->sin6_addr, entry->h_addr_list[0], entry->h_length);
#else
sin = (SOCKADDR_IN *)&addr;
sin->sin_family = AF_INET;
sin->sin_port = XHTONS(port);
XMEMCPY(&sin->sin_addr.s_addr, entry->h_addr_list[0], entry->h_length);
#endif
}

#if defined(__GLIBC__) && (__GLIBC__ >= 2) && defined(__USE_MISC) && \
Expand Down
2 changes: 1 addition & 1 deletion wolfssl/wolfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
#endif /* HAVE_SOCKADDR */

/* use gethostbyname for c99 */
#if defined(HAVE_GETADDRINFO) && !defined(WOLF_C99)
#if defined(HAVE_GETADDRINFO) || defined(WOLF_C99)
typedef struct addrinfo ADDRINFO;
#endif
#endif /* WOLFSSL_NO_SOCK */
Expand Down