--- openssl-0.9.7e/crypto/o_time.c
+++ openssl-0.9.7e/crypto/o_time.c
@@ -69,6 +69,20 @@
 # include <stdlib.h>
 #endif
 
+static OPENSSL_user_time_fn s_UserTimeFunction;
+void OPENSSL_install_user_time_function(OPENSSL_user_time_fn user_time_fn)
+{
+	s_UserTimeFunction = user_time_fn;
+}
+
+time_t OPENSSL_time(time_t *t)
+{
+	if(s_UserTimeFunction)
+		return s_UserTimeFunction(t);
+		
+	return time(t);
+}
+
 struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
 	{
 	struct tm *ts = NULL;
--- openssl-0.9.7e/crypto/o_time.h
+++ openssl-0.9.7e/crypto/o_time.h
@@ -63,4 +63,8 @@
 
 struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
 
+time_t OPENSSL_time(time_t *t);
+typedef time_t (* OPENSSL_user_time_fn)(time_t *t);
+void OPENSSL_install_user_time_function(OPENSSL_user_time_fn user_time_fn);
+
 #endif
--- openssl-0.9.7e/crypto/x509/x509_vfy.c
+++ openssl-0.9.7e/crypto/x509/x509_vfy.c
@@ -69,6 +69,7 @@
 #include <openssl/x509.h>
 #include <openssl/x509v3.h>
 #include <openssl/objects.h>
+#include "o_time.h"
 
 static int null_callback(int ok,X509_STORE_CTX *e);
 static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer);
@@ -1131,7 +1132,7 @@
 	int type = -1;
 
 	if (in_tm) t = *in_tm;
-	else time(&t);
+	else OPENSSL_time(&t);
 
 	t+=adj;
 	if (s) type = s->type;
