【发布时间】:2011-08-03 01:52:53
【问题描述】:
我不想检查需要客户端证书身份验证的网页。 如何将我的证书从 Certstore 提供给 Webrequest: 有没有办法在代理中的 Credentials odr 中指定这一点?
$webclient = New-Object Net.WebClient
# The next 5 lines are required if your network has a proxy server
$webclient.Credentials = [System.Net.CredentialCache]::DefaultCredentials
if($webclient.Proxy -ne $null) {
$webclient.Proxy.Credentials = `
[System.Net.CredentialCache]::DefaultNetworkCredentials
}
# This is the main call
$output = $webclient.DownloadString("$URL")
PS:也许这有帮助:How can you add a Certificate to WebClient (C#)? 但我不明白.. ;-)
【问题讨论】:
-
这个 SO 问题的意思是您要么必须直接使用 HttpWebRequest,要么覆盖 WebClient 以便添加证书。
标签: authentication powershell certificate webclient