2011-06-07 127 views

回答

1

使用:

certificate = new X509Certificate2("server.crt", "secret_password"); 
byte[] publicKey = certificate.PublicKey.EncodedKeyValue.RawData; 

現在「公鑰」字節數組是公鑰值的ASN.1編碼表示。

+1

'byte [] publicKey = certificate.GetPublicKey.EncodedKeyValue.RawData;'沒有爲我工作,不得不使用'byte [] publicKey = certificate.GetPublicKey();' – hs2d 2011-06-07 18:10:20

+0

好吧,這樣更適合你,重新直接使用公鑰。 – 2011-06-07 18:13:32

+0

如何從字節獲取公鑰?例如,我有公鑰(用EC算法生成,曲線「secp256r1」)和它在java上的編碼字節,我如何在c#中創建這些字節的公鑰? – Dadroid 2016-11-16 11:24:13