1
下面的代碼:「對象只包含密鑰對的公共一半,還必須提供私鑰。」使用2層。質子交換膜的與X509&MS Services3.Security
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("[email protected]"," ");
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,權威性,是我的公開證書和signCert,SOAP,是我的私有證書,但我真的很不確定。我從一種(Web服務)食譜中獲取代碼... Web服務表示他們沒有查看密碼。
的錯誤信息是:
"Object contains only the public half of a key pair. A private key must also be provided."