Last active
March 27, 2020 23:40
-
-
Save DamianEdwards/f1152eda6538989065f2287498e062a9 to your computer and use it in GitHub Desktop.
Self-signed certificate experiments
This file contains hidden or 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
# Generate root cert | |
$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature ` | |
-Subject "CN=AspNetCoreCertAuthRoot" -KeyExportPolicy Exportable ` | |
-HashAlgorithm sha256 -KeyLength 2048 ` | |
-CertStoreLocation "Cert:\CurrentUser\My" -KeyUsageProperty Sign -KeyUsage CertSign | |
# Make sure to trust this root cert | |
# Generate child cert with Client Authentication OID | |
New-SelfSignedCertificate -Type Custom -DnsName P2SChildCert -KeySpec Signature ` | |
-Subject "CN=AspNetCoreCertAuthClient-CertAuthTest-Client" -KeyExportPolicy Exportable ` | |
-HashAlgorithm sha256 -KeyLength 2048 ` | |
-CertStoreLocation "Cert:\CurrentUser\My" ` | |
-Signer $cert -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") | |
# Generate root cert | |
$rootCert = New-SelfSignedCertificate -Type Custom -KeySpec Signature ` | |
-Subject "CN=AspNetCoreCertAuthRoot" -KeyExportPolicy Exportable ` | |
-HashAlgorithm sha256 -KeyLength 2048 ` | |
-CertStoreLocation "Cert:\CurrentUser\My" -KeyUsageProperty Sign -KeyUsage CertSign | |
New-SelfSignedCertificate -Type Custom -Subject "CN=ClientAuthTest-Client" ` | |
-TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2","2.5.29.17={text}upn=ClientAuthTest-Client") ` | |
-KeyUsage DigitalSignature -KeyAlgorithm RSA -KeyLength 2048 ` | |
-CertStoreLocation "Cert:\CurrentUser\My" ` | |
-Signer $rootCert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment