Skip to content

Commit

Permalink
Support AsymmetricKeyParameter as return value of ReadPrivateKey() (q…
Browse files Browse the repository at this point in the history
  • Loading branch information
psqli authored Nov 8, 2021
1 parent 2d53436 commit c827518
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions assets/signing/sign-message.bouncycastle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ string SignMessage(string msg)
return Convert.ToBase64String(sig.GenerateSignature());
}

AsymmetricKeyParameter getPrivateKey() {
AsymmetricKeyParameter getPrivateKey()
{
using (var reader = System.IO.File.OpenText(privateKey))
return (new PemReader(reader, null).ReadObject() as AsymmetricCipherKeyPair).Private;
{
var pem = new PemReader(reader).ReadObject();
return pem as AsymmetricKeyParameter ?? (pem as AsymmetricCipherKeyPair).Private;
}
}


Expand All @@ -54,7 +58,10 @@ AsymmetricKeyParameter getPrivateKey() {

string certificate = "digital-certificate.txt";

string GetCertificate() {
string GetCertificate()
{
using (var reader = System.IO.File.OpenText(certificate))
{
return reader.ReadToEnd();
}
}

0 comments on commit c827518

Please sign in to comment.