简体   繁体   English

使用cer文件加密的Xml

[英]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.

相关问题 加密的整个XML文件 - Encrypted whole XML file 使用 IXmlSerializable (c#) 时加密的 XML 文件 - Encrypted XML file when using IXmlSerializable (c#) 导出加密的 XML 文件并在另一个应用程序中解密? - Exporting encrypted XML file and decrypt in another application? 读取/解密加密的XML文件,然后在内部进行处理 - Read/decrypt encrypted XML file and then process internally 如何从C#中的xml数字签名(.cer文件)获取信息? - How to obtain information from xml digital signature (.cer file) in C#? 使用Ruby连接到需要用户名,密码和安全证书(.cer文件)连接的Microsoft SOAP Web服务 - Using Ruby to connect to a Microsoft SOAP web service that requires a username, password and a security certificate (.cer file) to connect to it 使用文件上的 cer 或 pfx 从 Microsoft Graph 端点获取身份验证令牌 - Getting auth token from Microsoft Graph endpoint using cer or pfx on file 无法解密使用AesManaged加密的文件 - Unable to decrypt file encrypted using AesManaged 如何使用 AES (Rijndael) 检查文件是否加密 - How to Check If File is Encrypted using AES (Rijndael) 如何使用WindowsMediaPlayer播放加密的视频文件? - How to play encrypted video file using WindowsMediaPlayer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM