11

recently i got project need run it on .net core 1.1. i realize that RSACryptoServiceProvider is not exsit on .net core RSA class.

after i search in stackoverflow only few result as below =>

How to use RSA in .net Core

How to read a PEM RSA private key from .NET

C# Export Private/Public RSA key from RSACryptoServiceProvider to PEM string

this is what the above post to cues me that below link

https://gist.github.com/brentmaxwell/46081df6fcbc0ca33fe1

and i also research into bouncyCastle PCL 1.8.1.1 too.i still can't solve it

any 1 can help with below the pem format convert to XML format in .net core.

-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIZaRouD0ESme7+v
FefIW5aCyrjJWt1mkA5ITWfHHsFbZ8ErIWFTaysr95aLWIdHkEoBUi0lNKwnlQdP
V0/X5XNTJK03o/u+52424ppinZbog2nDSWYeuAwTe2zipdGB9COwJ/7TIgJyTLhX
fxAax7l6FxKmP6oXK7SJk5Ln5ZAlAgMBAAECgYBSatC5xxuc8XAab4KFlFAy7XsE
jmjSRpd6W3o4flrsjHECe73XYX/tlOQmEsc0/X6TF2pczWUZcpKmUFKkZTGYgM4q
ku0qimu9rsbMNFrro0R0weV2sq2sShRzN9qTXbDv/6ze6jn1gzDCSEAsb0LLtTQM
J2jH9zPm7tRzK8qAoQJBALr+EkQxZxDMe/TD7l15lFWH+DZPMGC9X7ZSafICzdgJ
u+XPAQiDOVFmtd/hEIF9ee7ifhc1Zf4NZy4QQGdrQT0CQQC37xvGZdrsteWaNrKF
QFVkG+zJ4gProhR1QDUB1LGOny+avL5mi+nbghJ7XwfI7NqFPYzTUjmNp3lVm5IG
O6kJAkAk9fdyVzmCDokp1liVTWTOizO6uGhdltEGXr/mQDujyjjDsekIX7fCqUSl
3fy/O6gQWeCGgd2JG+kbJ8czKfYZAkB0UuTm8S2mPFdL00HNoeUfHcX/20+NawCz
MnsTgFcWkrgBjVKA+gVZDIbxvSToPlronwd78elyG7NRn8SW6o45AkEAtB0nGH5Y
KXIS07CoQMRBHoXx4f+ojofNoJvzI5Ax+ZBbSx/z5hTSm/jN7llVFRE+3rRyNLig
X/r2O4vVkprHTg==
-----END PRIVATE KEY-----

result from https://superdry.apphb.com/tools/online-rsa-key-converter is work. but the bouncyCastle not many sample code .net core

Community
  • 1
  • 1
Neo Yap
  • 399
  • 1
  • 4
  • 9
  • It is not clear what you are trying to do. Try clarifying your question and cleaning up text. – George Whitaker Nov 13 '16 at 11:26
  • any way to convert from pem format to xml format? or any way to know what is this pem format. this can convert from bouncyCastle in old .net. but not in to .net core – Neo Yap Nov 13 '16 at 13:29
  • 5
    i solved it already now in my github https://github.com/neoyap/Rsa-Dotnet-Core – Neo Yap Nov 14 '16 at 14:56

1 Answers1

0
   PemReader pr = new PemReader(new StringReader(File.ReadAllText(pemfilepath)));
   RSAParameters rsaParams = pr.ReadPrivatekey();
   string gitHubAppIdentifier = appidentifier;
   var rsaProvider = new RSACryptoServiceProvider();
   rsaProvider.ImportParameters(rsaParams);
   var key = new RsaSecurityKey(rsaProvider);