这是代码:
using ADPTest.com.adp.hrbws;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Web.Services3.Security;
using Microsoft.Web.Services3.Security.Tokens;
using Microsoft.Web.Services3.Security.Cryptography;
namespace ADPTest
{
class Program
{
static void Main(string[] args)
{
// Create the web service proxy.
HrbService proxy = new HrbService();
// Add the Username token.
UsernameToken usernameToken = new UsernameToken("user@ABC"," ");
proxy.RequestSoapContext.Security.Tokens.Add(usernameToken);
// Add the certificate for mutual SSL.
X509Certificate2 mutualCert = new X509Certificate2 "I:\\auth.pem", " ");
proxy.ClientCertificates.Add(mutualCert);
// Sign the message using the signing certificate.
X509Certificate2 signCert = new X509Certificate2("I:\\soap.pem", " ");
X509SecurityToken signatureToken = new X509SecurityToken(signCert);
MessageSignature signature = new MessageSignature(signatureToken);
proxy.RequestSoapContext.Security.Elements.Add(signature);
我认为mutualCert,auth,是我的公共证书和signCert,SOAP,是我的私人证书,但我真的不确定。我从一种(网络服务)食谱中获取了代码......网络服务说他们不看密码。
错误信息是:
“对象仅包含密钥对的公共部分。还必须提供私钥。”