[英]Encrypted Xml using cer file
This websie 这个网站
http://msdn.microsoft.com/en-us/library/vstudio/ms148633(v=vs.100).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2 http://msdn.microsoft.com/en-us/library/vstudio/ms148633(v=vs.100).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2
encrypts XML using "test.pfx". 使用“ test.pfx”加密XML。
I want encipher my XML by X509 certificate and decrypt it using smart card. 我想通过X509证书加密我的XML,并使用智能卡对其解密。
I changed that line 我改变了那条线
X509Certificate2 cert = new X509Certificate2("test.pfx");
on 上
X509Certificate2 cert = new X509Certificate2("test.cer");
and my code encrypt XML and during decrypting I type my smard card pin and my XML is decrypted. 我的代码对XML进行了加密,并且在解密期间,我输入了smard卡的密码,并且对我的XML进行了解密。
When I use test.pfx I have to change code on 当我使用test.pfx时,我必须更改代码
X509Certificate2 cert = new X509Certificate2("test.pfx", "myPassword");
and this code encrypt XML but during decrypting I don't type my smard card pin and my XML is decrypted. 并且此代码对XML进行了加密,但是在解密过程中,我没有键入我的smard卡针,并且对我的XML进行了解密。
Can you explain me why on http://msdn.microsoft.com/ website to encrypt xml is using pfx file? 您能解释一下为什么在http://msdn.microsoft.com/网站上使用pfx文件加密xml的原因吗?
Does XML encrypted *.cer file is safe? XML加密的* .cer文件安全吗? I want decrypted my XML only by my smart card.
我只想通过智能卡解密XML。
A pfx file is similar to a PKCS#12 (.p12) file. pfx文件类似于PKCS#12(.p12)文件。 It usually contains a certificate and the correspondent private key.
它通常包含一个证书和相应的私钥。
A .cer file contains just a plain certificate without private key. .cer文件仅包含无私钥的普通证书。
According to the documentation the method EncryptedXml.Encrypt used in the referenced example wants to encrypt and sign the generated AES key that is used for encrypting the XML document. 根据文档,引用的示例中使用的方法EncryptedXml.Encrypt希望对生成的用于对XML文档进行加密的AES密钥进行加密和签名 。
For encryption the public key in the certificate is used. 为了加密,使用证书中的公钥。 However for signing the document the private key is required, I assume this is the reason a .pfx file is used.
但是,为签署文档需要私钥,我认为这就是使用.pfx文件的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.