2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System . IO ;
5
- using System . Text ;
6
5
using Xunit ;
7
6
8
7
namespace System . Security . Cryptography . X509Certificates . Tests
@@ -16,7 +15,7 @@ public static void X509CertTest()
16
15
const string CertSubject =
17
16
@"CN=Microsoft Corporate Root Authority, OU=ITG, O=Microsoft, L=Redmond, S=WA, C=US, [email protected] " ;
18
17
19
- using ( X509Certificate cert = new X509Certificate ( "TestData\\ microsoft.cer" ) )
18
+ using ( X509Certificate cert = new X509Certificate ( Path . Combine ( "TestData" , " microsoft.cer") ) )
20
19
{
21
20
Assert . Equal ( CertSubject , cert . Subject ) ;
22
21
Assert . Equal ( CertSubject , cert . Issuer ) ;
@@ -56,7 +55,10 @@ public static void X509Cert2Test()
56
55
const string CertName =
57
56
@"[email protected] , CN=ABA.ECOM Root CA, O=""ABA.ECOM, INC."", L=Washington, S=DC, C=US" ;
58
57
59
- using ( X509Certificate2 cert2 = new X509Certificate2 ( "TestData\\ test.cer" ) )
58
+ DateTime notBefore = new DateTime ( 1999 , 7 , 12 , 17 , 33 , 53 , DateTimeKind . Utc ) . ToLocalTime ( ) ;
59
+ DateTime notAfter = new DateTime ( 2009 , 7 , 9 , 17 , 33 , 53 , DateTimeKind . Utc ) . ToLocalTime ( ) ;
60
+
61
+ using ( X509Certificate2 cert2 = new X509Certificate2 ( Path . Combine ( "TestData" , "test.cer" ) ) )
60
62
{
61
63
Assert . Equal ( CertName , cert2 . IssuerName . Name ) ;
62
64
Assert . Equal ( CertName , cert2 . SubjectName . Name ) ;
@@ -67,8 +69,8 @@ public static void X509Cert2Test()
67
69
Assert . True ( pubKey . Key is RSACryptoServiceProvider ) ;
68
70
Assert . Equal ( "RSA" , pubKey . Oid . FriendlyName ) ;
69
71
70
- Assert . Equal ( new DateTime ( 2009 , 7 , 9 , 10 , 33 , 53 ) , cert2 . NotAfter ) ;
71
- Assert . Equal ( new DateTime ( 1999 , 7 , 12 , 10 , 33 , 53 ) , cert2 . NotBefore ) ;
72
+ Assert . Equal ( notAfter , cert2 . NotAfter ) ;
73
+ Assert . Equal ( notBefore , cert2 . NotBefore ) ;
72
74
73
75
Assert . Equal ( "00D01E4090000046520000000100000004" , cert2 . SerialNumber ) ;
74
76
Assert . Equal ( "1.2.840.113549.1.1.5" , cert2 . SignatureAlgorithm . Value ) ;
@@ -121,7 +123,7 @@ public static void X509Cert2ToStringVerbose()
121
123
[ ActiveIssue ( 1993 , PlatformID . AnyUnix ) ]
122
124
public static void X509Cert2CreateFromPfxFile ( )
123
125
{
124
- using ( X509Certificate2 cert2 = new X509Certificate2 ( "TestData\\ DummyTcpServer.pfx" ) )
126
+ using ( X509Certificate2 cert2 = new X509Certificate2 ( Path . Combine ( "TestData" , " DummyTcpServer.pfx") ) )
125
127
{
126
128
// OID=RSA Encryption
127
129
Assert . Equal ( "1.2.840.113549.1.1.1" , cert2 . GetKeyAlgorithm ( ) ) ;
@@ -132,7 +134,7 @@ public static void X509Cert2CreateFromPfxFile()
132
134
[ ActiveIssue ( 1993 , PlatformID . AnyUnix ) ]
133
135
public static void X509Cert2CreateFromPfxWithPassword ( )
134
136
{
135
- using ( X509Certificate2 cert2 = new X509Certificate2 ( "TestData\\ test.pfx" , "test" ) )
137
+ using ( X509Certificate2 cert2 = new X509Certificate2 ( Path . Combine ( "TestData" , " test.pfx") , "test" ) )
136
138
{
137
139
// OID=RSA Encryption
138
140
Assert . Equal ( "1.2.840.113549.1.1.1" , cert2 . GetKeyAlgorithm ( ) ) ;
0 commit comments