File tree Expand file tree Collapse file tree 3 files changed +23
-28
lines changed
ServiceControl.Audit.Persistence.RavenDB
ServiceControl.Persistence.RavenDB Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Original file line number Diff line number Diff line change 33namespace ServiceControl . Audit . Persistence . RavenDB
44{
55 using System ;
6- using System . IO ;
7- using System . Reflection ;
8- using System . Security . Cryptography . X509Certificates ;
96 using System . Threading ;
107 using System . Threading . Tasks ;
118 using Raven . Client . Documents ;
@@ -38,21 +35,11 @@ public async Task Initialize(CancellationToken cancellationToken = default)
3835 {
3936 await initializeSemaphore . WaitAsync ( cancellationToken ) ;
4037
41- // Look for raven-client-certificate.pfx in same directory as application code
42- var applicationDirectory = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) ? . Location ) ?? string . Empty ;
43- var certificatePath = Path . Combine ( applicationDirectory , "raven-client-certificate.pfx" ) ;
44- X509Certificate2 ? certificate = null ;
45-
46- if ( File . Exists ( certificatePath ) )
47- {
48- certificate = new X509Certificate2 ( certificatePath ) ;
49- }
50-
5138 var store = new DocumentStore
5239 {
5340 Database = configuration . Name ,
5441 Urls = [ configuration . ServerConfiguration . ConnectionString ] ,
55- Certificate = certificate ,
42+ Certificate = RavenClientCertificate . FindClientCertificate ( ) ,
5643 Conventions = new DocumentConventions
5744 {
5845 SaveEnumsAsIntegers = true
Original file line number Diff line number Diff line change 33namespace ServiceControl . Persistence . RavenDB
44{
55 using System ;
6- using System . IO ;
7- using System . Reflection ;
8- using System . Security . Cryptography . X509Certificates ;
96 using System . Threading ;
107 using System . Threading . Tasks ;
118 using Raven . Client . Documents ;
@@ -38,21 +35,11 @@ public async Task Initialize(CancellationToken cancellationToken)
3835 {
3936 await initializeSemaphore . WaitAsync ( cancellationToken ) ;
4037
41- // Look for raven-client-certificate.pfx in same directory as application code
42- var applicationDirectory = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) ? . Location ) ?? string . Empty ;
43- var certificatePath = Path . Combine ( applicationDirectory , "raven-client-certificate.pfx" ) ;
44- X509Certificate2 ? certificate = null ;
45-
46- if ( File . Exists ( certificatePath ) )
47- {
48- certificate = new X509Certificate2 ( certificatePath ) ;
49- }
50-
5138 var store = new DocumentStore
5239 {
5340 Database = settings . DatabaseName ,
5441 Urls = [ settings . ConnectionString ] ,
55- Certificate = certificate ,
42+ Certificate = RavenClientCertificate . FindClientCertificate ( ) ,
5643 Conventions = new DocumentConventions
5744 {
5845 SaveEnumsAsIntegers = true
Original file line number Diff line number Diff line change 1+ #nullable enable
2+
3+ namespace ServiceControl . RavenDB ;
4+
5+ using System . Reflection ;
6+ using System . Security . Cryptography . X509Certificates ;
7+
8+ public static class RavenClientCertificate
9+ {
10+ public static X509Certificate2 ? FindClientCertificate ( )
11+ {
12+ var applicationDirectory = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) ? . Location ) ?? string . Empty ;
13+ var certificatePath = Path . Combine ( applicationDirectory , "raven-client-certificate.pfx" ) ;
14+
15+ if ( File . Exists ( certificatePath ) )
16+ {
17+ return new X509Certificate2 ( certificatePath ) ;
18+ }
19+ return null ;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments