Use WSE to Encrypt SOAP packets (7)

Source: Internet
Author: User

Decrypt received packets
After receiving a message encrypted by the X.509 Certificate, SoapInputFilter automatically attempts to use the private key of the user key storage room for decryption. Of course, this requires to tell WSE where to find the additional configuration information for this certificate. This information is specified by the Security element of the application configuration file. In this example, the application configuration file on the client is App. config. For X.509 encryption, you only need to add an x509 subnode. The content is the same as the following.
<X509
StoreLocation = "CurrentUser"
VerifyTrust = "true"
AllowTestRoot = "false"/>
In my example, I set the storeLocation attribute of the x509 node to CurrentUser. Assume that the certificate is in the certificate store of the current user. When I use a trusted certificate from the CA, I also set verifyTrust to true. These attributes can also be modified using the WSE setting tool. With this information, WSE can obtain the private key of the message certificate, and can also use this to decrypt the symmetric session key. The decrypted content will eventually be decrypted to the message body.
Select the elements of the message used for decryption
After the entire message body is encrypted by default, WSE can be used to encrypt specific elements in the SOAP message. The only problem is that the elements in the Security Header element cannot be encrypted. You can also encrypt nested elements,
In this example, I modified the X.509 version used by the GetXmlDocument method, and used a secure Token based on X.509 to digitally encrypt EncryptedSubResponse AND ITS EncryptedResponse parent node, the returned XML file is as follows:
<Response>
<NotEncrypted>
There is no need to encrypt the Response Message.
</NotEncrypted>
<EncryptedResponse>
<EncryptedSubResponse>
This is sensitive data.
</EncryptedSubResponse>
</EncryptedResponse>
</Response>
To Encrypt an element, it requires a wsu: Id attribute so that XML can be referenced after being serialized and added to the node. The namespace wsu is defined:
Xmlns: wsu = "http://schemas.xmlsoap.org/ws/2002/07/utility

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.