Encrypt xml file in .net and decrypt in java using x509 certificate

illrshift

New Member
I spend almost a day searching on web for the following requirement and end with only encryption and decryption done in .net but not on java.I want to encrypt file in .net and decrypt it on java using x509Certificate \[code\]makecert -r -pe -n "CN=CERT_SIGN_TEST_CERT" -b 01/01/2010 -e 01/01/2012 -sky exchange -ss my\[/code\]using this command i generate certificate and exported .pfx file from certificate and this pfx file is used to encrypt the xml file\[quote\] in .net using EncryptedXml , X509Certificate2, RSACryptoServiceProvider and XmlDocument classes (.Net)\[/quote\]i encrypt following xml \[code\]<Test><Name>Foo</Name><CardNo>123</CardNo></Test>\[/code\]as follows:\[code\]<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#"><EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><X509Data><X509Certificate>MIICFzCCAYCgAwIBAgIQK5IFtxwNaJhGzXuDf92TgzANBgkqhkiG9w0BAQQFADAfMR0wGwYDVQQDHhQARgBpAG4AYQBsAF8AQwBlAHIAdDAeFw0wOTEyMzExODMwMDBaFw0xMjEyMzExODMwMDBaMB8xHTAbBgNVBAMeFABGAGkAbgBhAGwAXwBDAGUAcgB0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1Wx11luboMbT1swXV/56j2RYRhR81n9hF3b6tfof1zHRorg7DIP3hvnVtqDF+WxAjn1um97DHtxWf3solthbIHC9cGtqxUhZhgdd0aVAuiKTBbTgnOWdEqTErenrHOzlZnD9iDzOm3OYVLKN+3hKJmjlhTp0sFsu4AIbXlxZVHQIDAQABo1QwUjBQBgNVHQEESTBHgBBDXPlnSZ5zUyVbxJzJO12goSEwHzEdMBsGA1UEAx4UAEYAaQBuAGEAbABfAEMAZQByAHSCECuSBbccDWiYRs17g3/dk4MwDQYJKoZIhvcNAQEEBQADgYEAiubZJZdF3Y9ItOl7LTyixcbuebs50GLFsTeMslS3usq6psXcUEFJntXJ5vXOSe/vp6E6A5AwW4MtPfnB1kzach4T4+WlWeaDHoyj6y5j+n7P6B/X6ZhkQ8MCiGhZ/fTOt7CDisnFVG9gvoH2LUEs1QkiByDq6jii3TUAMN9YQdA=</X509Certificate></X509Data></KeyInfo><CipherData><CipherValue>Vyml+mtbeL5bE6EWKNqHfnE1xEkbJglcxbjH3Y7pj9BtXVImAI/SbBdLHatyjIAei7qUfhcn+qYC7WAh48XR78BgqCdJX7O5lfZjVSVeVaQUwl1Bdirdz7RYuveIjDtEIM80W4tB6rq2nOgYNkisxhhwIl7EiCQtT42bSGCKFic=</CipherValue></CipherData></EncryptedKey></KeyInfo><CipherData><CipherValue>ezVeQlBGZRbHqitB2mmHuMvifGB9IhG1g0CWmL8iz37JIIw7x5cGbb5Ap8iy24ACu8TJpwgAGIUWnUTDSZ//kWLzCa3G5HL+jT/RHn+zypk=</CipherValue></CipherData></EncryptedData>\[/code\]as far as encryption is done using w3c standard. How can i decrypt this xml file on java. I have used .pfx file to encrypt the file. In .net i can decrypt file using following:\[code\] EncryptedXml encXml = new EncryptedXml(xmlEncDoc); encXml.DecryptDocument();\[/code\]How can i decrypt in java, should i pass pfx file to java end? as there is \[code\]<X509Data>\[/code\] tag in encrypted xml file.your suggestion is appriciated.
 
Back
Top