0
我正在使用某些服務並使用服務提供者給出了證書。附加客戶端證書時出現禁止403錯誤
因此,我已經在LocalMachine上安裝了證書,並通過下面的代碼將證書與我要發佈的Web請求附加在一起,以便從Web服務獲取響應。
X509Certificate cert = null;
string ResponseXml = string.Empty;
// Represents an X.509 store, which is a physical store
// where certificates are persisted and managed
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection results =
certStore.Certificates.Find(X509FindType.FindBySubjectDistinguishedName,
Constants.CertificateName, false);
certStore.Close();
if (results != null && results.Count > 0)
cert = results[0];
else
{
ErrorMessage = "Certificate not found";
return ErrorMessage;
}
webClient.TransportSettings.ClientCertificates.Add(cert);
當我使用ASP.net Cassini(ASP.NET開發服務器)運行代碼時,此功能非常完美。
但是,當我在託管這個代碼IIS 7.0它給禁止403錯誤作爲響應。
請建議。