如何使用公钥加密SOAP请求 [英] How do I encrypt a SOAP request using a public key
问题描述
大家好,
在我的一个应用程序中,我需要调用一个Web服务.Web服务使用OASIS标准。条件如下:
A)请求必须使用用户的私钥进行数字签名。签名
包含密钥包含X.509证书详细信息的info元素。这需要
服务器来验证签名者。必须签署SOAP请求中的以下元素
时间戳
用户名提示
正文
B)签名后,请求必须使用电子归档的公钥加密
使用URI https://incometaxindiaefiling.gov.in/ eFiling / Portal / WebServiceIncomeTaxPublicKey.cer下载公钥。
以下内容使用公钥加密
UsernameToken
Body
Hi all,
In one of my application I need to invoke a web service.The web service uses OASIS standard. The conditions are as follows:
A ) The request has to be digitally signed using the private key of the user.Signature
include key info element that contains X.509 certificate details.This is needed for
server to validate the signer.The below elements in the SOAP request has to be signed
Timestamp
UsernameToken
Body
B) After signing, the request has to be encrypted using the e-Filing’s public key
Use the URI https://incometaxindiaefiling.gov.in/eFiling/Portal/WebServiceIncomeTaxPublicKey.cer to download the public key.
The below contents are encrypted using the public key
UsernameToken
Body
BulkPanService Servicee = new BulkPanService();
// Create the UsernameToken we use to sign the message
UsernameToken userToken;
userToken = new UsernameToken("XXXXXX", "XXXXX", PasswordOption.SendHashed);
Servicee.SetClientCredential(userToken);
// Adds the token to the SOAP header.
SoapContext context = Servicee.RequestSoapContext;
context.Security.Timestamp.TtlInSeconds = 60000;
context.Security.Tokens.Add(userToken);
MessageSignature sig = new MessageSignature(signatureToken);
sig.SignatureOptions = SignatureOptions.IncludeTimestamp | SignatureOptions.IncludeSoapBody;
context.Security.Elements.Add(sig);
BulkPanRequest request = new BulkPanRequest();
request.uniqueRequestId = "XXXXXXXX";
FileStream stream = File.OpenRead(@"path");
byte[] fileBytes = new byte[stream.Length];
stream.Read(fileBytes, 0, fileBytes.Length);
stream.Close();
request.dataHandler = fileBytes;
// First of all create an encrypting token
X509SecurityToken encryptingToken = GetServerToken();
// Encrypt the UsernameToken element in the SOAP header
Servicee.RequestSoapContext.Security.Elements.Add(new EncryptedData(encryptingToken));
BulkPanResponse response = new BulkPanResponse();
response = Servicee.uploadBulkPan(request);
但是当
But when
Servicee.RequestSoapContext.Security.Elements.Add(new EncryptedData(encryptingToken));
行执行抛出错误
line executes It is throwing error
WSE527: The SecurityToken does not support data encryption.
。
请知道如何调用具有上述条件的web服务的人,帮我排序这个问题。
谢谢
.
Please anyone who knows how to invoke the webservice with the above condition, help me to sort this issue.
Thank You
推荐答案
你好,你找到任何解决方案。如果是,请指导我。
Hello, do you find any solution. If yes, Please guide me.
这篇关于如何使用公钥加密SOAP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!