@@ -888,6 +888,7 @@ func testResumption(t *testing.T, version uint16) {
888
888
MaxVersion : version ,
889
889
CipherSuites : []uint16 {TLS_RSA_WITH_RC4_128_SHA , TLS_ECDHE_RSA_WITH_RC4_128_SHA },
890
890
Certificates : testConfig .Certificates ,
891
+ Time : testTime ,
891
892
}
892
893
893
894
issuer , err := x509 .ParseCertificate (testRSACertificateIssuer )
@@ -904,6 +905,7 @@ func testResumption(t *testing.T, version uint16) {
904
905
ClientSessionCache : NewLRUClientSessionCache (32 ),
905
906
RootCAs : rootCAs ,
906
907
ServerName : "example.golang" ,
908
+ Time : testTime ,
907
909
}
908
910
909
911
testResumeState := func (test string , didResume bool ) {
@@ -951,20 +953,20 @@ func testResumption(t *testing.T, version uint16) {
951
953
}
952
954
953
955
// An old session ticket can resume, but the server will provide a ticket encrypted with a fresh key.
954
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * time .Hour + time .Minute ) }
956
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * time .Hour + time .Minute ) }
955
957
testResumeState ("ResumeWithOldTicket" , true )
956
958
if bytes .Equal (ticket [:ticketKeyNameLen ], getTicket ()[:ticketKeyNameLen ]) {
957
959
t .Fatal ("old first ticket matches the fresh one" )
958
960
}
959
961
960
962
// Now the session tickey key is expired, so a full handshake should occur.
961
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * 8 * time .Hour + time .Minute ) }
963
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * 8 * time .Hour + time .Minute ) }
962
964
testResumeState ("ResumeWithExpiredTicket" , false )
963
965
if bytes .Equal (ticket , getTicket ()) {
964
966
t .Fatal ("expired first ticket matches the fresh one" )
965
967
}
966
968
967
- serverConfig .Time = func () time. Time { return time . Now () } // reset the time back
969
+ serverConfig .Time = testTime // reset the time back
968
970
key1 := randomKey ()
969
971
serverConfig .SetSessionTicketKeys ([][32 ]byte {key1 })
970
972
@@ -981,11 +983,11 @@ func testResumption(t *testing.T, version uint16) {
981
983
testResumeState ("KeyChangeFinish" , true )
982
984
983
985
// Age the session ticket a bit, but not yet expired.
984
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * time .Hour + time .Minute ) }
986
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * time .Hour + time .Minute ) }
985
987
testResumeState ("OldSessionTicket" , true )
986
988
ticket = getTicket ()
987
989
// Expire the session ticket, which would force a full handshake.
988
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * 8 * time .Hour + time .Minute ) }
990
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * 8 * time .Hour + time .Minute ) }
989
991
testResumeState ("ExpiredSessionTicket" , false )
990
992
if bytes .Equal (ticket , getTicket ()) {
991
993
t .Fatal ("new ticket wasn't provided after old ticket expired" )
@@ -995,15 +997,14 @@ func testResumption(t *testing.T, version uint16) {
995
997
d := 0 * time .Hour
996
998
for i := 0 ; i < 13 ; i ++ {
997
999
d += 12 * time .Hour
998
- serverConfig .Time = func () time.Time { return time . Now ().Add (d ) }
1000
+ serverConfig .Time = func () time.Time { return testTime ().Add (d ) }
999
1001
testResumeState ("OldSessionTicket" , true )
1000
1002
}
1001
1003
// Expire it (now a little more than 7 days) and make sure a full
1002
1004
// handshake occurs for TLS 1.2. Resumption should still occur for
1003
1005
// TLS 1.3 since the client should be using a fresh ticket sent over
1004
1006
// by the server.
1005
- d += 12 * time .Hour
1006
- serverConfig .Time = func () time.Time { return time .Now ().Add (d ) }
1007
+ d += 12 * time .Hour + time .Minute
1007
1008
if version == VersionTLS13 {
1008
1009
testResumeState ("ExpiredSessionTicket" , true )
1009
1010
} else {
@@ -1019,6 +1020,7 @@ func testResumption(t *testing.T, version uint16) {
1019
1020
MaxVersion : version ,
1020
1021
CipherSuites : []uint16 {TLS_RSA_WITH_RC4_128_SHA , TLS_ECDHE_RSA_WITH_RC4_128_SHA },
1021
1022
Certificates : testConfig .Certificates ,
1023
+ Time : testTime ,
1022
1024
}
1023
1025
serverConfig .SetSessionTicketKeys ([][32 ]byte {key2 })
1024
1026
@@ -1707,6 +1709,7 @@ func testVerifyConnection(t *testing.T, version uint16) {
1707
1709
Certificates : []Certificate {testConfig .Certificates [0 ]},
1708
1710
ClientCAs : rootCAs ,
1709
1711
NextProtos : []string {"protocol1" },
1712
+ Time : testTime ,
1710
1713
}
1711
1714
serverConfig .Certificates [0 ].SignedCertificateTimestamps = [][]byte {[]byte ("dummy sct 1" ), []byte ("dummy sct 2" )}
1712
1715
serverConfig .Certificates [0 ].OCSPStaple = []byte ("dummy ocsp" )
@@ -1719,6 +1722,7 @@ func testVerifyConnection(t *testing.T, version uint16) {
1719
1722
ServerName : "example.golang" ,
1720
1723
Certificates : []Certificate {testConfig .Certificates [0 ]},
1721
1724
NextProtos : []string {"protocol1" },
1725
+ Time : testTime ,
1722
1726
}
1723
1727
test .configureClient (clientConfig , & clientCalled )
1724
1728
@@ -2007,7 +2011,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) {
2007
2011
config .ServerName = "example.golang"
2008
2012
config .ClientAuth = RequireAndVerifyClientCert
2009
2013
config .ClientCAs = rootCAs
2010
- config .Time = now
2014
+ config .Time = testTime
2011
2015
config .MaxVersion = version
2012
2016
config .Certificates = make ([]Certificate , 1 )
2013
2017
config .Certificates [0 ].Certificate = [][]byte {testRSACertificate }
@@ -2338,7 +2342,7 @@ func testGetClientCertificate(t *testing.T, version uint16) {
2338
2342
serverConfig .RootCAs = x509 .NewCertPool ()
2339
2343
serverConfig .RootCAs .AddCert (issuer )
2340
2344
serverConfig .ClientCAs = serverConfig .RootCAs
2341
- serverConfig .Time = func () time. Time { return time . Unix ( 1476984729 , 0 ) }
2345
+ serverConfig .Time = testTime
2342
2346
serverConfig .MaxVersion = version
2343
2347
2344
2348
clientConfig := testConfig .Clone ()
@@ -2513,6 +2517,7 @@ func testResumptionKeepsOCSPAndSCT(t *testing.T, ver uint16) {
2513
2517
ClientSessionCache : NewLRUClientSessionCache (32 ),
2514
2518
ServerName : "example.golang" ,
2515
2519
RootCAs : roots ,
2520
+ Time : testTime ,
2516
2521
}
2517
2522
serverConfig := testConfig .Clone ()
2518
2523
serverConfig .MaxVersion = ver
0 commit comments