@@ -886,6 +886,7 @@ func testResumption(t *testing.T, version uint16) {
886
886
MaxVersion : version ,
887
887
CipherSuites : []uint16 {TLS_RSA_WITH_RC4_128_SHA , TLS_ECDHE_RSA_WITH_RC4_128_SHA },
888
888
Certificates : testConfig .Certificates ,
889
+ Time : testTime ,
889
890
}
890
891
891
892
issuer , err := x509 .ParseCertificate (testRSACertificateIssuer )
@@ -902,6 +903,7 @@ func testResumption(t *testing.T, version uint16) {
902
903
ClientSessionCache : NewLRUClientSessionCache (32 ),
903
904
RootCAs : rootCAs ,
904
905
ServerName : "example.golang" ,
906
+ Time : testTime ,
905
907
}
906
908
907
909
testResumeState := func (test string , didResume bool ) {
@@ -949,20 +951,20 @@ func testResumption(t *testing.T, version uint16) {
949
951
}
950
952
951
953
// An old session ticket can resume, but the server will provide a ticket encrypted with a fresh key.
952
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * time .Hour + time .Minute ) }
954
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * time .Hour + time .Minute ) }
953
955
testResumeState ("ResumeWithOldTicket" , true )
954
956
if bytes .Equal (ticket [:ticketKeyNameLen ], getTicket ()[:ticketKeyNameLen ]) {
955
957
t .Fatal ("old first ticket matches the fresh one" )
956
958
}
957
959
958
960
// Now the session tickey key is expired, so a full handshake should occur.
959
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * 8 * time .Hour + time .Minute ) }
961
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * 8 * time .Hour + time .Minute ) }
960
962
testResumeState ("ResumeWithExpiredTicket" , false )
961
963
if bytes .Equal (ticket , getTicket ()) {
962
964
t .Fatal ("expired first ticket matches the fresh one" )
963
965
}
964
966
965
- serverConfig .Time = func () time. Time { return time . Now () } // reset the time back
967
+ serverConfig .Time = testTime // reset the time back
966
968
key1 := randomKey ()
967
969
serverConfig .SetSessionTicketKeys ([][32 ]byte {key1 })
968
970
@@ -979,11 +981,11 @@ func testResumption(t *testing.T, version uint16) {
979
981
testResumeState ("KeyChangeFinish" , true )
980
982
981
983
// Age the session ticket a bit, but not yet expired.
982
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * time .Hour + time .Minute ) }
984
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * time .Hour + time .Minute ) }
983
985
testResumeState ("OldSessionTicket" , true )
984
986
ticket = getTicket ()
985
987
// Expire the session ticket, which would force a full handshake.
986
- serverConfig .Time = func () time.Time { return time . Now ().Add (24 * 8 * time .Hour + time .Minute ) }
988
+ serverConfig .Time = func () time.Time { return testTime ().Add (24 * 8 * time .Hour + 2 * time .Minute ) }
987
989
testResumeState ("ExpiredSessionTicket" , false )
988
990
if bytes .Equal (ticket , getTicket ()) {
989
991
t .Fatal ("new ticket wasn't provided after old ticket expired" )
@@ -993,15 +995,14 @@ func testResumption(t *testing.T, version uint16) {
993
995
d := 0 * time .Hour
994
996
for i := 0 ; i < 13 ; i ++ {
995
997
d += 12 * time .Hour
996
- serverConfig .Time = func () time.Time { return time . Now ().Add (d ) }
998
+ serverConfig .Time = func () time.Time { return testTime ().Add (d ) }
997
999
testResumeState ("OldSessionTicket" , true )
998
1000
}
999
1001
// Expire it (now a little more than 7 days) and make sure a full
1000
1002
// handshake occurs for TLS 1.2. Resumption should still occur for
1001
1003
// TLS 1.3 since the client should be using a fresh ticket sent over
1002
1004
// by the server.
1003
- d += 12 * time .Hour
1004
- serverConfig .Time = func () time.Time { return time .Now ().Add (d ) }
1005
+ d += 12 * time .Hour + time .Minute
1005
1006
if version == VersionTLS13 {
1006
1007
testResumeState ("ExpiredSessionTicket" , true )
1007
1008
} else {
@@ -1017,6 +1018,7 @@ func testResumption(t *testing.T, version uint16) {
1017
1018
MaxVersion : version ,
1018
1019
CipherSuites : []uint16 {TLS_RSA_WITH_RC4_128_SHA , TLS_ECDHE_RSA_WITH_RC4_128_SHA },
1019
1020
Certificates : testConfig .Certificates ,
1021
+ Time : testTime ,
1020
1022
}
1021
1023
serverConfig .SetSessionTicketKeys ([][32 ]byte {key2 })
1022
1024
@@ -1655,6 +1657,7 @@ func testVerifyConnection(t *testing.T, version uint16) {
1655
1657
Certificates : []Certificate {testConfig .Certificates [0 ]},
1656
1658
ClientCAs : rootCAs ,
1657
1659
NextProtos : []string {"protocol1" },
1660
+ Time : testTime ,
1658
1661
}
1659
1662
serverConfig .Certificates [0 ].SignedCertificateTimestamps = [][]byte {[]byte ("dummy sct 1" ), []byte ("dummy sct 2" )}
1660
1663
serverConfig .Certificates [0 ].OCSPStaple = []byte ("dummy ocsp" )
@@ -1667,6 +1670,7 @@ func testVerifyConnection(t *testing.T, version uint16) {
1667
1670
ServerName : "example.golang" ,
1668
1671
Certificates : []Certificate {testConfig .Certificates [0 ]},
1669
1672
NextProtos : []string {"protocol1" },
1673
+ Time : testTime ,
1670
1674
}
1671
1675
test .configureClient (clientConfig , & clientCalled )
1672
1676
@@ -1708,8 +1712,6 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) {
1708
1712
rootCAs := x509 .NewCertPool ()
1709
1713
rootCAs .AddCert (issuer )
1710
1714
1711
- now := func () time.Time { return time .Unix (1476984729 , 0 ) }
1712
-
1713
1715
sentinelErr := errors .New ("TestVerifyPeerCertificate" )
1714
1716
1715
1717
verifyPeerCertificateCallback := func (called * bool , rawCerts [][]byte , validatedChains [][]* x509.Certificate ) error {
@@ -1955,7 +1957,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) {
1955
1957
config .ServerName = "example.golang"
1956
1958
config .ClientAuth = RequireAndVerifyClientCert
1957
1959
config .ClientCAs = rootCAs
1958
- config .Time = now
1960
+ config .Time = testTime
1959
1961
config .MaxVersion = version
1960
1962
config .Certificates = make ([]Certificate , 1 )
1961
1963
config .Certificates [0 ].Certificate = [][]byte {testRSACertificate }
@@ -1972,7 +1974,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) {
1972
1974
config := testConfig .Clone ()
1973
1975
config .ServerName = "example.golang"
1974
1976
config .RootCAs = rootCAs
1975
- config .Time = now
1977
+ config .Time = testTime
1976
1978
config .MaxVersion = version
1977
1979
test .configureClient (config , & clientCalled )
1978
1980
clientErr := Client (c , config ).Handshake ()
@@ -2286,7 +2288,7 @@ func testGetClientCertificate(t *testing.T, version uint16) {
2286
2288
serverConfig .RootCAs = x509 .NewCertPool ()
2287
2289
serverConfig .RootCAs .AddCert (issuer )
2288
2290
serverConfig .ClientCAs = serverConfig .RootCAs
2289
- serverConfig .Time = func () time. Time { return time . Unix ( 1476984729 , 0 ) }
2291
+ serverConfig .Time = testTime
2290
2292
serverConfig .MaxVersion = version
2291
2293
2292
2294
clientConfig := testConfig .Clone ()
@@ -2461,6 +2463,7 @@ func testResumptionKeepsOCSPAndSCT(t *testing.T, ver uint16) {
2461
2463
ClientSessionCache : NewLRUClientSessionCache (32 ),
2462
2464
ServerName : "example.golang" ,
2463
2465
RootCAs : roots ,
2466
+ Time : testTime ,
2464
2467
}
2465
2468
serverConfig := testConfig .Clone ()
2466
2469
serverConfig .MaxVersion = ver
0 commit comments