66using Org . BouncyCastle . OpenSsl ;
77
88
9- namespace Icarus . Certs
9+ namespace Icarus . Certs ;
10+
11+ public class SigningIssuerCertificate : IDisposable
1012{
11- public class SigningIssuerCertificate : IDisposable
13+ private readonly RSACryptoServiceProvider _rsa ;
14+
15+ public SigningIssuerCertificate ( )
1216 {
13- private readonly RSACryptoServiceProvider _rsa ;
17+ _rsa = new RSACryptoServiceProvider ( ) ;
18+ }
1419
15- public SigningIssuerCertificate ( )
16- {
17- _rsa = new RSACryptoServiceProvider ( ) ;
18- }
20+ public RsaSecurityKey GetIssuerSigningKey ( string publicKeyPath )
21+ {
22+ var file = publicKeyPath ;
23+ var publicKey = System . IO . File . ReadAllText ( file ) ;
1924
20- public RsaSecurityKey GetIssuerSigningKey ( string publicKeyPath )
25+ using ( var reader = System . IO . File . OpenText ( file ) )
2126 {
22- var file = publicKeyPath ;
23- var publicKey = System . IO . File . ReadAllText ( file ) ;
24-
25- using ( var reader = System . IO . File . OpenText ( file ) )
26- {
27- var pem = new PemReader ( reader ) ;
28- var o = ( RsaKeyParameters ) pem . ReadObject ( ) ;
29- var parameters = new RSAParameters ( ) ;
30- parameters . Modulus = o . Modulus . ToByteArray ( ) ;
31- parameters . Exponent = o . Exponent . ToByteArray ( ) ;
32- _rsa . ImportParameters ( parameters ) ;
33- }
34-
35- return new RsaSecurityKey ( _rsa ) ;
27+ var pem = new PemReader ( reader ) ;
28+ var o = ( RsaKeyParameters ) pem . ReadObject ( ) ;
29+ var parameters = new RSAParameters ( ) ;
30+ parameters . Modulus = o . Modulus . ToByteArray ( ) ;
31+ parameters . Exponent = o . Exponent . ToByteArray ( ) ;
32+ _rsa . ImportParameters ( parameters ) ;
3633 }
3734
35+ return new RsaSecurityKey ( _rsa ) ;
36+ }
3837
39- public void Dispose ( )
40- {
41- _rsa ? . Dispose ( ) ;
42- }
38+
39+ public void Dispose ( )
40+ {
41+ _rsa ? . Dispose ( ) ;
4342 }
43+ }
4444
4545
46- public class SigningAudienceCertificate : IDisposable
46+ public class SigningAudienceCertificate : IDisposable
47+ {
48+ private readonly RSACryptoServiceProvider _rsa ;
49+
50+ public SigningAudienceCertificate ( )
4751 {
48- private readonly RSACryptoServiceProvider _rsa ;
52+ _rsa = new RSACryptoServiceProvider ( ) ;
53+ }
4954
50- public SigningAudienceCertificate ( )
51- {
52- _rsa = new RSACryptoServiceProvider ( ) ;
53- }
55+ public SigningCredentials GetAudienceSigningKey ( string keyPath )
56+ {
57+ var file = keyPath ;
58+ var publicKey = System . IO . File . ReadAllText ( file ) ;
5459
55- public SigningCredentials GetAudienceSigningKey ( string keyPath )
60+ using ( var reader = System . IO . File . OpenText ( file ) )
5661 {
57- var file = keyPath ;
58- var publicKey = System . IO . File . ReadAllText ( file ) ;
59-
60- using ( var reader = System . IO . File . OpenText ( file ) )
61- {
62- var pem = new PemReader ( reader ) ;
63- var o = ( RsaKeyParameters ) pem . ReadObject ( ) ;
64- var parameters = new RSAParameters ( ) ;
65- parameters . Modulus = o . Modulus . ToByteArray ( ) ;
66- parameters . Exponent = o . Exponent . ToByteArray ( ) ;
67- _rsa . ImportParameters ( parameters ) ;
68- }
69-
70- return new SigningCredentials (
71- key : new RsaSecurityKey ( _rsa ) ,
72- algorithm : SecurityAlgorithms . RsaSha256 ) ;
62+ var pem = new PemReader ( reader ) ;
63+ var o = ( RsaKeyParameters ) pem . ReadObject ( ) ;
64+ var parameters = new RSAParameters ( ) ;
65+ parameters . Modulus = o . Modulus . ToByteArray ( ) ;
66+ parameters . Exponent = o . Exponent . ToByteArray ( ) ;
67+ _rsa . ImportParameters ( parameters ) ;
7368 }
7469
75- public void Dispose ( )
76- {
77- _rsa ? . Dispose ( ) ;
78- }
70+ return new SigningCredentials (
71+ key : new RsaSecurityKey ( _rsa ) ,
72+ algorithm : SecurityAlgorithms . RsaSha256 ) ;
73+ }
74+
75+ public void Dispose ( )
76+ {
77+ _rsa ? . Dispose ( ) ;
7978 }
80- }
79+ }
0 commit comments