-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcert_setup.ps1
More file actions
30 lines (23 loc) · 952 Bytes
/
cert_setup.ps1
File metadata and controls
30 lines (23 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#Requires -RunAsAdministrator
$localCertsPath = ".\local_certs"
$localCertsExtensionPath = ".\local_certs\openssl.conf"
$localCertsExtensionContents = @"
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
CN = localhost
[v3_req]
subjectAltName = @alt_names
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
[alt_names]
DNS.1 = localhost
"@
New-Item -ItemType Directory -Path $localCertsPath
New-Item -ItemType File -Path $localCertsExtensionPath
$localCertsExtensionContents | Out-File -FilePath $localCertsExtensionPath -Encoding UTF8
openssl req -x509 -newkey rsa:2048 -sha256 -nodes -days 365 -keyout local_certs/private.key -out local_certs/certificate.crt -config local_certs/openssl.conf
import-certificate -filepath local_certs\certificate.crt -certstorelocation Cert:\LocalMachine\Root