Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Optionally pass the individual enrollment cert expiry duration
Browse files Browse the repository at this point in the history
  • Loading branch information
abhipsaMisra authored and davilu committed Nov 8, 2019
1 parent 1a373eb commit 9100254
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ https://github.com/azure/azure-iot-sdk-csharp
#>

Param(
$deviceName = "iothubx509device1"
$deviceName = "iothubx509device1",
$certificateValidityInYears = 1
)

$cert = New-SelfSignedCertificate -Type Custom -Subject "CN=$deviceName, O=TEST, C=US" -KeySpec Signature -KeyExportPolicy Exportable -HashAlgorithm sha256 -KeyLength 2048 -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") -CertStoreLocation "Cert:\CurrentUser\My"
$cert = New-SelfSignedCertificate -Type Custom -Subject "CN=$deviceName, O=TEST, C=US" -KeySpec Signature -KeyExportPolicy Exportable -HashAlgorithm sha256 -KeyLength 2048 -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2") -CertStoreLocation "Cert:\CurrentUser\My" -NotAfter (Get-Date).AddYears($certificateValidityInYears)

Write-Host "Generated the certificate:"
Write-Host $cert
Expand Down
4 changes: 4 additions & 0 deletions provisioning/Samples/device/X509Sample/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ The sample code is set up to use X.509 certificates stored within a password-pro

`powershell .\GenerateTestCertificate.ps1`

You can optionally pass the DeviceID and generated certificate validity duration to the powershell script:

`powershell .\GenerateTestCertificate.ps1 -deviceName "iothubx509device1" -certificateValidityInYears 10`

The script will prompt for a PFX password. The same password must be used when running the sample.

In your Device Provisioning Service go to "Manage enrollments" and select "Individual Enrollments".
Expand Down

0 comments on commit 9100254

Please sign in to comment.