@@ -100,7 +100,7 @@ public async Task Initialize(
100100 id . StoreType = CertificateStoreIdentifier . DetermineStoreType ( id . StorePath ) ;
101101 id . SubjectName = application . CertificateSubjectName . Replace ( "localhost" , Utils . GetHostName ( ) ) ;
102102
103- certificate = await id . Find ( true ) ;
103+ certificate = await id . FindAsync ( true ) ;
104104 }
105105 }
106106 }
@@ -131,7 +131,7 @@ public async Task Initialize(
131131 SubjectName = "CN=" + url . DnsSafeHost
132132 } ;
133133
134- certificate = await id . Find ( ) ;
134+ certificate = await id . FindAsync ( ) ;
135135 }
136136 }
137137 }
@@ -170,31 +170,31 @@ private async void RequestNewButton_Click(object sender, EventArgs e)
170170 {
171171 if ( m_application . RegistrationType == RegistrationType . ServerPush )
172172 {
173- RequestNewCertificatePushMode ( sender , e ) ;
173+ RequestNewCertificatePushMode ( sender , e ) . GetAwaiter ( ) . GetResult ( ) ;
174174 }
175175 else
176176 {
177177 await RequestNewCertificatePullMode ( sender , e ) ;
178178 }
179179 }
180180
181- private void RequestNewCertificatePushMode ( object sender , EventArgs e )
181+ private async Task RequestNewCertificatePushMode ( object sender , EventArgs e )
182182 {
183183 try
184184 {
185- NodeId trustListId = m_gds . GetTrustList ( m_application . ApplicationId , NodeId . Null ) ;
186- var trustList = m_gds . ReadTrustList ( trustListId ) ;
187- bool applyChanges = m_server . UpdateTrustList ( trustList ) ;
185+ NodeId trustListId = await m_gds . GetTrustListAsync ( m_application . ApplicationId , NodeId . Null ) ;
186+ var trustList = await m_gds . ReadTrustListAsync ( trustListId ) ;
187+ bool applyChanges = await m_server . UpdateTrustListAsync ( trustList ) ;
188188
189189 byte [ ] unusedNonce = new byte [ 0 ] ;
190- byte [ ] certificateRequest = m_server . CreateSigningRequest (
190+ byte [ ] certificateRequest = await m_server . CreateSigningRequestAsync (
191191 NodeId . Null ,
192192 m_server . ApplicationCertificateType ,
193193 string . Empty ,
194194 false ,
195195 unusedNonce ) ;
196196 var domainNames = m_application . GetDomainNames ( m_certificate ) ;
197- NodeId requestId = m_gds . StartSigningRequest (
197+ NodeId requestId = await m_gds . StartSigningRequestAsync (
198198 m_application . ApplicationId ,
199199 NodeId . Null ,
200200 NodeId . Null ,
@@ -236,7 +236,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
236236 StorePath = m_application . CertificateStorePath ,
237237 SubjectName = Utils . ReplaceDCLocalhost ( m_application . CertificateSubjectName )
238238 } ;
239- m_certificate = await id . Find ( true ) ;
239+ m_certificate = await id . FindAsync ( true ) ;
240240 //test if private key is available & exportable, else create new temporary certificate for csr
241241 if ( m_certificate != null &&
242242 m_certificate . HasPrivateKey )
@@ -246,7 +246,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
246246 //this line fails with a CryptographicException if export of private key is not allowed
247247 _ = m_certificate . GetRSAPrivateKey ( ) . ExportParameters ( true ) ;
248248 //proceed with a CSR using the exportable private key
249- m_certificate = await id . LoadPrivateKey ( m_certificatePassword ) ;
249+ m_certificate = await id . LoadPrivateKeyAsync ( m_certificatePassword ) ;
250250 }
251251 catch
252252 {
@@ -276,14 +276,14 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
276276 if ( m_certificate == null )
277277 {
278278 // no private key
279- requestId = m_gds . StartNewKeyPairRequest (
279+ requestId = m_gds . StartNewKeyPairRequestAsync (
280280 m_application . ApplicationId ,
281281 NodeId . Null ,
282282 NodeId . Null ,
283283 Utils . ReplaceDCLocalhost ( m_application . CertificateSubjectName ) ,
284284 domainNames ,
285285 "PFX" ,
286- m_certificatePassword ) ;
286+ m_certificatePassword ) . GetAwaiter ( ) . GetResult ( ) ;
287287 }
288288 else
289289 {
@@ -296,7 +296,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
296296 {
297297 string absoluteCertificatePrivateKeyPath = Utils . GetAbsoluteFilePath ( m_application . CertificatePrivateKeyPath , true , false , false ) ;
298298 byte [ ] pkcsData = File . ReadAllBytes ( absoluteCertificatePrivateKeyPath ) ;
299- if ( m_application . GetPrivateKeyFormat ( m_server ? . GetSupportedKeyFormats ( ) ) == "PFX" )
299+ if ( m_application . GetPrivateKeyFormat ( m_server ? . GetSupportedKeyFormatsAsync ( ) . GetAwaiter ( ) . GetResult ( ) ) == "PFX" )
300300 {
301301 csrCertificate = X509PfxUtils . CreateCertificateFromPKCS12 ( pkcsData , m_certificatePassword ) ;
302302 }
@@ -306,7 +306,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
306306 }
307307 }
308308 byte [ ] certificateRequest = CertificateFactory . CreateSigningRequest ( csrCertificate , domainNames ) ;
309- requestId = m_gds . StartSigningRequest ( m_application . ApplicationId , NodeId . Null , NodeId . Null , certificateRequest ) ;
309+ requestId = m_gds . StartSigningRequestAsync ( m_application . ApplicationId , NodeId . Null , NodeId . Null , certificateRequest ) . GetAwaiter ( ) . GetResult ( ) ;
310310 }
311311
312312 m_application . CertificateRequestId = requestId . ToString ( ) ;
@@ -365,12 +365,12 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
365365 // in this case, privateKey is null
366366 if ( privateKeyPFX == null )
367367 {
368- X509Certificate2 oldCertificate = await cid . Find ( true ) ;
368+ X509Certificate2 oldCertificate = await cid . FindAsync ( true ) ;
369369 if ( oldCertificate != null && oldCertificate . HasPrivateKey )
370370 {
371- oldCertificate = await cid . LoadPrivateKey ( string . Empty ) ;
371+ oldCertificate = await cid . LoadPrivateKeyAsync ( string . Empty ) ;
372372 newCert = CertificateFactory . CreateCertificateWithPrivateKey ( newCert , m_temporaryCertificateCreated ? m_certificate : oldCertificate ) ;
373- await store . Delete ( oldCertificate . Thumbprint ) ;
373+ await store . DeleteAsync ( oldCertificate . Thumbprint ) ;
374374 }
375375 else
376376 {
@@ -382,7 +382,7 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
382382 newCert = new X509Certificate2 ( privateKeyPFX , string . Empty , X509KeyStorageFlags . Exportable ) ;
383383 newCert = CertificateFactory . Load ( newCert , true ) ;
384384 }
385- await store . Add ( newCert ) ;
385+ await store . AddAsync ( newCert ) ;
386386 if ( m_temporaryCertificateCreated )
387387 {
388388 m_certificate . Dispose ( ) ;
@@ -423,7 +423,7 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
423423 }
424424
425425 // if we provided a PFX or P12 with the private key, we need to merge the new cert with the private key
426- if ( m_application . GetPrivateKeyFormat ( m_server ? . GetSupportedKeyFormats ( ) ) == "PFX" )
426+ if ( m_application . GetPrivateKeyFormat ( m_server ? . GetSupportedKeyFormatsAsync ( ) . GetAwaiter ( ) . GetResult ( ) ) == "PFX" )
427427 {
428428 string absoluteCertificatePrivateKeyPath = Utils . GetAbsoluteFilePath ( m_application . CertificatePrivateKeyPath , true , false , false ) ?? m_application . CertificatePrivateKeyPath ;
429429 file = new FileInfo ( absoluteCertificatePrivateKeyPath ) ;
@@ -471,10 +471,10 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
471471 foreach ( byte [ ] issuerCertificate in issuerCertificates )
472472 {
473473 X509Certificate2 x509 = new X509Certificate2 ( issuerCertificate ) ;
474- X509Certificate2Collection certs = await store . FindByThumbprint ( x509 . Thumbprint ) ;
474+ X509Certificate2Collection certs = await store . FindByThumbprintAsync ( x509 . Thumbprint ) ;
475475 if ( certs . Count == 0 )
476476 {
477- await store . Add ( new X509Certificate2 ( issuerCertificate ) ) ;
477+ await store . AddAsync ( new X509Certificate2 ( issuerCertificate ) ) ;
478478 }
479479 }
480480 }
@@ -492,13 +492,13 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
492492 }
493493
494494 byte [ ] unusedPrivateKey = new byte [ 0 ] ;
495- bool applyChanges = m_server . UpdateCertificate (
495+ bool applyChanges = m_server . UpdateCertificateAsync (
496496 NodeId . Null ,
497497 m_server . ApplicationCertificateType ,
498498 certificate ,
499499 ( privateKeyPFX != null ) ? "pfx" : String . Empty ,
500500 ( privateKeyPFX != null ) ? privateKeyPFX : unusedPrivateKey ,
501- issuerCertificates ) ;
501+ issuerCertificates ) . GetAwaiter ( ) . GetResult ( ) ;
502502 if ( applyChanges )
503503 {
504504 MessageBox . Show (
@@ -533,7 +533,7 @@ private void ApplyChangesButton_Click(object sender, EventArgs e)
533533 ApplyChangesButton . Enabled = false ;
534534 try
535535 {
536- m_server . ApplyChanges ( ) ;
536+ m_server . ApplyChangesAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
537537 }
538538 catch ( Exception exception )
539539 {
@@ -547,7 +547,7 @@ private void ApplyChangesButton_Click(object sender, EventArgs e)
547547
548548 try
549549 {
550- m_server . Disconnect ( ) ;
550+ m_server . DisconnectAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
551551 }
552552 catch ( Exception )
553553 {
0 commit comments