forked from wolfSSL/wolfssl
Merge pull request #3358 from douzzer/wolfSSL_get_ocsp_producedDate
add wolfSSL_get_ocsp_producedDate().
This commit is contained in:
41
configure.ac
41
configure.ac
@@ -67,11 +67,46 @@ AC_CHECK_SIZEOF([long long])
|
||||
AC_CHECK_SIZEOF([long])
|
||||
AC_CHECK_SIZEOF([time_t])
|
||||
AC_CHECK_TYPES([__uint128_t])
|
||||
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r inet_ntoa memset socket])
|
||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stddef.h sys/ioctl.h sys/socket.h sys/time.h errno.h])
|
||||
|
||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stddef.h time.h sys/ioctl.h sys/socket.h sys/time.h errno.h])
|
||||
AC_CHECK_LIB([network],[socket])
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
# check if functions of interest are linkable, but also check if
|
||||
# they're declared by the expected headers, and if not, supersede the
|
||||
# unusable positive from AC_CHECK_FUNCS().
|
||||
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday gmtime_r inet_ntoa memset socket strftime])
|
||||
AC_CHECK_DECLS([gethostbyname, getaddrinfo, gettimeofday, gmtime_r, inet_ntoa, memset, socket, strftime], [], [
|
||||
if test "$(eval echo \$"$(eval 'echo ac_cv_func_${as_decl_name}')")" = "yes"
|
||||
then
|
||||
echo " note: earlier check for $(eval 'echo ${as_decl_name}') superseded."
|
||||
eval "$(eval 'echo ac_cv_func_${as_decl_name}=no')"
|
||||
_mask_varname=HAVE_`eval "echo '${as_decl_name}'" | tr 'a-z' 'A-Z'`
|
||||
echo "g/#define $_mask_varname 1/s//\/* #undef $_mask_varname *\//
|
||||
wq
|
||||
." | ed -s confdefs.h
|
||||
fi
|
||||
], [[
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
]])
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_TYPE_SIZE_T
|
||||
AC_TYPE_UINT8_T
|
||||
@@ -2163,7 +2198,9 @@ fi
|
||||
if test "$ENABLED_STACKSIZE" = "yes"
|
||||
then
|
||||
AC_CHECK_FUNC([posix_memalign], [], [AC_MSG_ERROR(stacksize needs posix_memalign)])
|
||||
AC_CHECK_DECL([posix_memalign], [], [AC_MSG_ERROR(stacksize needs posix_memalign)])
|
||||
AC_CHECK_FUNC([pthread_attr_setstack], [], AC_CHECK_LIB([pthread],[pthread_attr_setstack]))
|
||||
AC_CHECK_DECL([pthread_attr_setstack], [], [AC_MSG_ERROR(stacksize needs pthread_attr_setstack)], [[#include <pthread.h>]])
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_STACK_SIZE"
|
||||
fi
|
||||
|
||||
|
@@ -3007,6 +3007,26 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||
|
||||
showPeerEx(ssl, lng_index);
|
||||
|
||||
#if defined(HAVE_OCSP) && !defined(NO_ASN_TIME)
|
||||
#ifdef HAVE_STRFTIME
|
||||
{
|
||||
struct tm tm;
|
||||
char date[32];
|
||||
ret = wolfSSL_get_ocsp_producedDate_tm(ssl, &tm);
|
||||
if ((ret == 0) && (strftime(date, sizeof date, "%Y-%m-%d %H:%M:%S %z", &tm) > 0))
|
||||
printf("OCSP response timestamp: %s\n", date);
|
||||
}
|
||||
#else
|
||||
{
|
||||
byte date[MAX_DATE_SIZE];
|
||||
int asn_date_format;
|
||||
ret = wolfSSL_get_ocsp_producedDate(ssl, date, sizeof date, &asn_date_format);
|
||||
if (ret == 0)
|
||||
printf("OCSP response timestamp: %s (ASN.1 type %d)\n", (char *)date, asn_date_format);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
printf("Session timeout set to %ld seconds\n", wolfSSL_get_timeout(ssl));
|
||||
{
|
||||
|
@@ -9857,6 +9857,11 @@ static int ProcessCSR(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
||||
else if (response->status->status != CERT_GOOD)
|
||||
ret = BAD_CERTIFICATE_STATUS_ERROR;
|
||||
|
||||
else {
|
||||
XMEMCPY(ssl->ocspProducedDate, response->producedDate, sizeof ssl->ocspProducedDate);
|
||||
ssl->ocspProducedDateFormat = response->producedDateFormat;
|
||||
}
|
||||
|
||||
*inOutIdx += status_length;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
|
41
src/ssl.c
41
src/ssl.c
@@ -44161,6 +44161,47 @@ int wolfSSL_set_ocsp_url(WOLFSSL* ssl, char* url)
|
||||
#endif /* OCSP */
|
||||
#endif /* OPENSSL_ALL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
|
||||
|
||||
#if defined(HAVE_OCSP) && !defined(NO_ASN_TIME)
|
||||
int wolfSSL_get_ocsp_producedDate(
|
||||
WOLFSSL *ssl,
|
||||
byte *producedDate,
|
||||
size_t producedDate_space,
|
||||
int *producedDateFormat)
|
||||
{
|
||||
if ((ssl->ocspProducedDateFormat != ASN_UTC_TIME) &&
|
||||
(ssl->ocspProducedDateFormat != ASN_GENERALIZED_TIME))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if ((producedDate == NULL) || (producedDateFormat == NULL))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (XSTRLEN((char *)ssl->ocspProducedDate) >= producedDate_space)
|
||||
return BUFFER_E;
|
||||
|
||||
XSTRNCPY((char *)producedDate, (const char *)ssl->ocspProducedDate, producedDate_space);
|
||||
*producedDateFormat = ssl->ocspProducedDateFormat;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wolfSSL_get_ocsp_producedDate_tm(WOLFSSL *ssl, struct tm *produced_tm) {
|
||||
int idx = 0;
|
||||
|
||||
if ((ssl->ocspProducedDateFormat != ASN_UTC_TIME) &&
|
||||
(ssl->ocspProducedDateFormat != ASN_GENERALIZED_TIME))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (produced_tm == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (ExtractDate(ssl->ocspProducedDate, ssl->ocspProducedDateFormat, produced_tm, &idx))
|
||||
return 0;
|
||||
else
|
||||
return ASN_PARSE_E;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
|
||||
defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
|
||||
int wolfSSL_CTX_get_extra_chain_certs(WOLFSSL_CTX* ctx, WOLF_STACK_OF(X509)** chain)
|
||||
|
@@ -4167,6 +4167,8 @@ struct WOLFSSL {
|
||||
#endif /* HAVE_TLS_EXTENSIONS */
|
||||
#ifdef HAVE_OCSP
|
||||
void* ocspIOCtx;
|
||||
byte ocspProducedDate[MAX_DATE_SZ];
|
||||
int ocspProducedDateFormat;
|
||||
#ifdef OPENSSL_EXTRA
|
||||
byte* ocspResp;
|
||||
int ocspRespSz;
|
||||
|
@@ -3735,6 +3735,16 @@ WOLFSSL_API void *wolfSSL_OPENSSL_memdup(const void *data,
|
||||
WOLFSSL_API void wolfSSL_ERR_load_BIO_strings(void);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OCSP) && !defined(NO_ASN_TIME)
|
||||
WOLFSSL_API int wolfSSL_get_ocsp_producedDate(
|
||||
WOLFSSL *ssl,
|
||||
byte *producedDate,
|
||||
size_t producedDate_space,
|
||||
int *producedDateFormat);
|
||||
WOLFSSL_API int wolfSSL_get_ocsp_producedDate_tm(WOLFSSL *ssl,
|
||||
struct tm *produced_tm);
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_ALL) \
|
||||
|| defined(WOLFSSL_NGINX) \
|
||||
|| defined(WOLFSSL_HAPROXY) \
|
||||
|
Reference in New Issue
Block a user