Skip to content

Instantly share code, notes, and snippets.

@tinohager
Last active September 30, 2020 14:42
Show Gist options
  • Save tinohager/dcf050c416c3fc058db015ddd96228fa to your computer and use it in GitHub Desktop.
Save tinohager/dcf050c416c3fc058db015ddd96228fa to your computer and use it in GitHub Desktop.
Generating self-signed certificate on windows
$url = "https://github.com/IndySockets/OpenSSL-Binaries/raw/master/openssl-1.0.2s-x64_86-win64.zip"
$zipPath = "$PSScriptRoot\openssl.zip"
$openSslPath = "$PSScriptRoot\openssl"
$openSsl = "$($openSslPath)\openssl.exe"
Invoke-WebRequest -Uri $url -OutFile $zipPath
Expand-Archive $zipPath -DestinationPath $openSslPath
&$openSsl genrsa -out private.key 4096
&$openSsl req -new -sha256 -out private.csr -key private.key -config ssl.conf
&$openSsl req -text -noout -in private.csr
&$openSsl x509 -req -days 3650 -in private.csr -signkey private.key -out private.crt -extensions req_ext -extfile ssl.conf
[req]
default_bits = 4096
distinguished_name = req_distinguished_name
req_extensions = req_ext
prompt = no
[req_distinguished_name]
countryName = AT
stateOrProvinceName = Austria
localityName = Vienna
organizationName = MyCompany
commonName = localhost
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
#DNS.2 = another-website.dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment