Fix Visual Studio compiling errors

This commit is contained in:
Zhi Guan
2022-10-06 14:23:30 +08:00
parent ad023d33f7
commit 58fda1f721
3 changed files with 26 additions and 6 deletions

View File

@@ -25,6 +25,10 @@
#include <gmssl/x509.h>
#include <gmssl/error.h>
#ifdef WIN32
#include "u_time.h"
#endif
const char *x509_version_name(int version)
{
@@ -97,7 +101,11 @@ int x509_time_to_der(time_t tv, uint8_t **out, size_t *outlen)
int ret;
struct tm tm_val;
#ifdef WIN32
GMSSL_gmtime(&tv, &tm_val);
#else
gmtime_r(&tv, &tm_val);
#endif
if (tm_val.tm_year < 2050 - 1900) {
if ((ret = asn1_utc_time_to_der(tv, out, outlen)) != 1) {
if (ret < 0) error_print();
@@ -136,7 +144,11 @@ int x509_validity_add_days(time_t *not_after, time_t not_before, int days)
error_print();
return -1;
}
#ifdef WIN32
GMSSL_gmtime(&not_before, &tm_val);
#else
gmtime_r(&not_before, &tm_val);
#endif
tm_val.tm_mday += days;
*not_after = mktime(&tm_val);
return 1;