@@ -99,15 +99,10 @@ public void KeyAndCertImport(
99
99
var testDevice = IntegrationTestDeviceEnumeration . GetTestDevice ( testDeviceType ) ;
100
100
Assert . True ( testDevice . EnabledUsbCapabilities . HasFlag ( YubiKeyCapabilities . Piv ) ) ;
101
101
102
- using var pivSession = new PivSession ( testDevice ) ;
103
- var isValid = PivSupport . ResetPiv ( pivSession ) ;
104
- Assert . True ( isValid ) ;
105
-
106
- var collectorObj = new Simple39KeyCollector ( ) ;
107
- pivSession . KeyCollector = collectorObj . Simple39KeyCollectorDelegate ;
102
+ using var pivSession = GetSession ( testDevice ) ;
108
103
109
104
var testPrivateKey = TestKeys . GetTestPrivateKey ( keyType ) ;
110
- var testCert = TestKeys . GetTestCertificate ( keyType ) ;
105
+ var testCert = TestKeys . GetTestCertificate ( keyType ) ;
111
106
var privateKey = AsnPrivateKeyDecoder . CreatePrivateKey ( testPrivateKey . EncodedKey ) ;
112
107
113
108
pivSession . ImportPrivateKey ( 0x90 , privateKey ) ;
@@ -129,17 +124,14 @@ public void CertImport(
129
124
var testDevice = IntegrationTestDeviceEnumeration . GetTestDevice ( testDeviceType ) ;
130
125
Assert . True ( testDevice . EnabledUsbCapabilities . HasFlag ( YubiKeyCapabilities . Piv ) ) ;
131
126
132
- var isValid = SampleKeyPairs . GetMatchingKeyAndCert ( keyType , out var cert , out var _ ) ;
133
- Assert . True ( isValid ) ;
134
-
135
- using var pivSession = new PivSession ( testDevice ) ;
136
- var collectorObj = new Simple39KeyCollector ( ) ;
137
- pivSession . KeyCollector = collectorObj . Simple39KeyCollectorDelegate ;
127
+ var testCertificate = TestKeys . GetTestCertificate ( keyType ) ;
128
+ var testX509Certificate = testCertificate . AsX509Certificate2 ( ) ;
138
129
139
- pivSession . ImportCertificate ( 0x90 , cert ! ) ;
130
+ using var pivSession = GetSession ( testDevice ) ;
131
+ pivSession . ImportCertificate ( 0x90 , testX509Certificate ) ;
140
132
141
- var getCert = pivSession . GetCertificate ( 0x90 ) ;
142
- Assert . True ( getCert . Equals ( cert ) ) ;
133
+ var resultCert = pivSession . GetCertificate ( 0x90 ) ;
134
+ Assert . True ( resultCert . Equals ( testX509Certificate ) ) ;
143
135
}
144
136
145
137
[ SkippableTheory ( typeof ( NotSupportedException ) , typeof ( DeviceNotFoundException ) ) ]
@@ -155,19 +147,16 @@ public void ImportCompressedCert(KeyType keyType, StandardTestDevice testDeviceT
155
147
var testDevice = IntegrationTestDeviceEnumeration . GetTestDevice ( testDeviceType ) ;
156
148
Assert . True ( testDevice . EnabledUsbCapabilities . HasFlag ( YubiKeyCapabilities . Piv ) ) ;
157
149
158
- var isValid = SampleKeyPairs . GetMatchingKeyAndCert ( keyType , out var cert , out var _ ) ;
159
- Assert . True ( isValid ) ;
160
-
161
- using var pivSession = new PivSession ( testDevice ) ;
162
- var collectorObj = new Simple39KeyCollector ( ) ;
163
- pivSession . KeyCollector = collectorObj . Simple39KeyCollectorDelegate ;
150
+ var testCertificate = TestKeys . GetTestCertificate ( keyType ) ;
151
+ var testX509Certificate = testCertificate . AsX509Certificate2 ( ) ;
164
152
165
- pivSession . ImportCertificate ( 0x91 , cert ! , true ) ;
153
+ using var pivSession = GetSession ( testDevice ) ;
154
+ pivSession . ImportCertificate ( 0x91 , testX509Certificate , true ) ;
166
155
167
- var getCert = pivSession . GetCertificate ( 0x91 ) ;
168
- Assert . True ( getCert . Equals ( cert ) ) ;
156
+ var resultCert = pivSession . GetCertificate ( 0x91 ) ;
157
+ Assert . True ( resultCert . Equals ( testX509Certificate ) ) ;
169
158
}
170
-
159
+
171
160
private static PivSession GetSession (
172
161
IYubiKeyDevice testDevice )
173
162
{
0 commit comments