Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download the SSL certificate from a website using PowerShell?

I want to download the SSL certificate from, say https://www.outlook.com, using PowerShell. Is it possible? Could someone help me?

like image 973
RafaMarrara Avatar asked Mar 06 '14 19:03

RafaMarrara


People also ask

How do I get certificate information in PowerShell?

You can access the certificate store using MMC or using CertMgr. msc command. There are certificates stored for CurrentUser, ServiceAccount, and Local Computer. To access the certificate store using PowerShell, you need to access the PSDrive, and Certificates are stored in the drive called Cert as you can see below.

Can I download a SSL certificate?

You can also download the certificate from the admin page for that certificate. After logging in, click “SSL Certificates” in the left navigation menu. Click on the name of the certificate you want to download. Click on “Download”.


1 Answers

To share more knowledge :-)

$webRequest = [Net.WebRequest]::Create("https://www.outlook.com")
try { $webRequest.GetResponse() } catch {}
$cert = $webRequest.ServicePoint.Certificate
$bytes = $cert.Export([Security.Cryptography.X509Certificates.X509ContentType]::Cert)
set-content -value $bytes -encoding byte -path "$pwd\Outlook.Com.cer"

My co-worker Michael J. Lyons shared this with me.

like image 150
RafaMarrara Avatar answered Sep 22 '22 05:09

RafaMarrara