Skip to content

Instantly share code, notes, and snippets.

@MattHodge
Created December 14, 2013 21:56
Show Gist options
  • Save MattHodge/7965434 to your computer and use it in GitHub Desktop.
Save MattHodge/7965434 to your computer and use it in GitHub Desktop.
Get-ChildItem Cert:\LocalMachine\Root | Where-Object {$_.Subject -eq 'CN=SubjectName'} | Foreach-Object { [system.IO.file]::WriteAllBytes("C:\SSL\SubjectName.pfx",($_.Export('PFX', 'p@ssw0rd')) ) }
Makecert -r -pe -n CN="www.website.com" -b 02/01/2014 -e 12/22/2099 -eku 1.3.6.1.5.5.7.3.1 -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -len 4096 -a sha1 website.cer
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$result = Invoke-WebRequest -Uri "https://IpAddress/resource"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment