Last active
August 26, 2021 13:51
-
-
Save dfbaskin/81e721f99ce972e12629d29177046575 to your computer and use it in GitHub Desktop.
Using .NET Core Development Certificates with Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$certsPath = Join-Path $PSScriptRoot "certs" | |
if(!(Test-Path $certsPath)) { | |
New-Item -Path $PSScriptRoot -Name "certs" -ItemType "directory" | Out-Null | |
} | |
Push-Location $certsPath | |
$gitPath = $env:Path.Split(';') | | |
Where-Object { Test-Path $_ } | | |
Get-ChildItem -Filter git.exe | | |
ForEach-Object { Join-Path -Resolve $_.Directory ".." } | |
$openSSL = Join-Path $gitPath "usr/bin/openssl.exe" | |
if(!(Test-Path $openSSL)) { | |
throw "Could not find OpenSSL.exe" | |
} | |
dotnet dev-certs https --clean | |
if(-not $?) { exit } | |
$key = "1234" | |
dotnet dev-certs https --export-path "dev_localhost.pfx" --password $key --trust --verbose | |
if(-not $?) { exit } | |
& $openSSL pkcs12 -in ./dev_localhost.pfx -clcerts -nokeys -out ./dev_localhost.crt -passin "pass:$key" | |
if(-not $?) { exit } | |
& $openSSL pkcs12 -in ./dev_localhost.pfx -nocerts -nodes -out ./dev_localhost.key -passin "pass:$key" | |
if(-not $?) { exit } | |
Get-ChildItem | |
Pop-Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment