I want to download the SSL certificate from, say https://www.outlook.com, using PowerShell. Is it possible? Could someone help me?
相关问题
- How to Debug/Register a Permanent WMI Event Which
- Mechanize getting “Errno::ECONNRESET: Connection r
- How can I do variable substitution in a here-strin
- How to use a default value with parameter sets in
- Can ServiceStack JsonServiceClient send a get requ
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- C#调用PowerShell的问题
- ssl配置问题
- Intermittent “sslv3 alert handshake failure” under
- EscapeDataString having differing behaviour betwee
- Making a two way SSL authentication between apache
- decrypt TLS 1.2 AES-GCM packet
- PowerShell Change owner of files and folders
To share more knowledge :-)
My co-worker Michael J. Lyons shared this with me.
You should be able to get the public key by using the
ServicePoint
property on theHttpWebRequest
object. This necessary information will be populated once we have made a http request to the site in question.If the request is made to a site which has an untrusted certificate the GetResponse method will throw an exception, However, the
ServicePoint
will still contain theCertificate
so we want to ensure we ignoreWebException
if the status is a trust failure.So something like the following should work:
If you want to call the method many times and some might have the same address, you might want to improve the function by using the
ServicePointManager.FindServicePoint(System.Uri)
method, since it will return a cached version if a request has already been made to that site. So you could check if the service point has been populated with information. If it hasn't, make the web request. If it has, just use the already existing information, saving yourself an http request.From http://poshcode.org/2521:
I successfully used these functions like this: