Last active
June 14, 2019 20:42
-
-
Save ridomin/9f1dad25727bddd4a34b77a66b82c795 to your computer and use it in GitHub Desktop.
CreateTestCertificateChain.ps1
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
$RootCACert= New-SelfSignedCertificate -KeyUsage KeyEncipherment, DataEncipherment, CertSign -HashAlgorithm SHA256 -KeyUsageProperty All -KeyLength 4096 -Subject "1TestRootCA" -FriendlyName "testRoot" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -certstorelocation cert:\CurrentUser\My -dnsname "RidoITHub.azure-devices.net" -TextExtension @("2.5.29.19 ={text}ca=1&pathlength=3") | |
$IMCACert = New-SelfSignedCertificate -KeyUsage KeyEncipherment, DataEncipherment, CertSign -HashAlgorithm SHA256 -KeyUsageProperty All -KeyLength 4096 -Subject "1TestSubCA01" -FriendlyName "SubCA-01" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -certstorelocation cert:\CurrentUser\my -dnsname "RidoITHub.azure-devices.net" -TextExtension @("2.5.29.19 ={text}ca=1&pathlength=0") -Signer $RootCACert | |
$TestCert = New-SelfSignedCertificate -KeyUsage KeyEncipherment, DataEncipherment -HashAlgorithm SHA256 -KeyUsageProperty All -KeyLength 4096 -Subject "1test-device01" -FriendlyName "Test-Device-01" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -certstorelocation cert:\CurrentUser\my -dnsname "RidoITHub.azure-devices.net" -Signer $IMCACert | |
$RootCACert | |
$IMCACert | |
$TestCert | |
Export-Certificate -Cert $RootCACert -FilePath 1TestRootCA.cer -Type CERT | |
Export-Certificate -Cert $IMCACert -FilePath 1TestSubCA.cer -Type CERT | |
Export-Certificate -Cert $TestCert -FilePath 1TestDevice1.cer -Type CERT | |
$mypwd = ConvertTo-SecureString -String "1234" -Force -AsPlainText | |
Export-PfxCertificate -Cert $RootCACert -FilePath 1TestRootCA.pfx -Password $mypwd | |
Export-PfxCertificate -Cert $IMCACert -FilePath 1TestSubCA.pfx -Password $mypwd | |
Export-PfxCertificate -Cert $TestCert -FilePath 1TestDevice1.pfx -Password $mypwd | |
Import-Certificate -FilePath 1TestRootCA.cer -CertStoreLocation Cert:\LocalMachine\Root |
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
$subca = gci cert:\CurrentUser\My\DE2045EB8567FDE12D64DB026F89CCB5F41CE9AC | |
$EdgeDeviceCert = New-SelfSignedCertificate -KeyUsage KeyEncipherment, DataEncipherment, CertSign -HashAlgorithm SHA256 -KeyUsageProperty All -KeyLength 4096 -Subject "rido-iotedge" -FriendlyName "rido-iotEdge" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -certstorelocation cert:\CurrentUser\my -Signer $subca | |
Export-Certificate -Cert $EdgeDeviceCert -FilePath rido-iotedge.cer -Type CERT | |
Export-PfxCertificate -Cert $EdgeDeviceCert -FilePath rido-iotedge.pfx -Password $pwd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test Device
-----BEGIN CERTIFICATE-----
MIIFVTCCAz2gAwIBAgIQKoSmSGRue55KCzabzXGCPzANBgkqhkiG9w0BAQsFADAX
MRUwEwYDVQQDDAwxVGVzdFN1YkNBMDEwHhcNMTkwNjA3MDYyNzI5WhcNMjAwNjA3
MDY0NzI3WjAZMRcwFQYDVQQDDA4xdGVzdC1kZXZpY2UwMTCCAiIwDQYJKoZIhvcN
AQEBBQADggIPADCCAgoCggIBAL6WaSk6gf82c+zMQmpJDx4CYi7mGWiiUfn5/05+
eg6yT8FWfNIf344VDvIPoR/EPvlglleAUTj5n8fMQPNx403/tAluvM5olI1RdC9/
wgI3+WjwwKseMxvNqBzIZkICjGKZ5DweHlfjudRxTPiINdDNXM/uyPgHzJEqVoIg
VEvRkG+BTlIWj8YDmTrz4/hE50Rx5anWPEIn7RXAydVlXE5xPAxnV83a3Duqcg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