Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
typeflat

Prerequisites

  • For Austin CA certificates, the computer referenced in the following instructions must have Enroll permissions for the requested certificate template
    • Contact the AD team for assistance with certificate template permissions

Define the certificate subject and subject alternative names

  1. Sign in to a computer

...

  1. then start

...

  1. an administrative PowerShell session 

...

  1. Modify then run the following commands to set the subject and template of the certificate as well as any optional DNS or IP Address subject alternate name values:  

    Code Block

...

  1. languagepowershell
    $Subject = 

...

  1. "<subject for the certificate>"
    

...

  1. $SubjectAlternateNames = @("<certificate SAN #1>","<certificate SAN #2>",...)
    

...

  1. $CertificateIPAddresses = @("<certificate IP address #1>","<certificate IP address #2>",...)

Create the certificate request

  1. Run the following commands to define the newline string: 

    Code Block
    languagepowershell
    $NewLine = [System.Environment]::NewLine
  2. Run the following commands to create the temporary files

...

  1. Code Block

...

  1. languagepowershell
    $CertificateTemplateFile = New-TemporaryFile
    

...

  1. $CertificateRequestFile = New-TemporaryFile
  2. Run the following commands to

...

  1. define the certificate template

...

  1. :

...

Certreq reference: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certreq_1

Quick notes on the template contents:

Expand

Exportable = this allows the certificate to be exported by Windows

MachineKeySet = specifies that certificates will be created in the computer store instead of the user running the commands; requires Administrator privileges to perform

...

  1. Code Block
    languagepowershell
    $CertificateTemplate = @

...

  1. '
    [Version]
    Signature=

...

  1. "

...

  1. $Windows 

...

  1. NT$"
      
    [NewRequest]
    Subject=

...

  1. "CN=

...

  1. %Subject%"
    Exportable=TRUE
    MachineKeySet=TRUE
    KeyLength=2048
    KeySpec=AT_KEYEXCHANGE
      
    [Extensions]
    2.5.29.17=

...

  1. "{text}

...

  1. "
    _continue_=

...

  1. "DNS=

...

  1. %Subject%&

...

  1. "
    

...

  1. '@
  2. Run the following commands to update the subject in the certificate template: 

    Code Block
    languagepowershell
    $CertificateTemplate = $CertificateTemplate.Replace('%Subject%', $Subject)
  3. Run the following commands to add any optional DNS subject alternate names to the certificate

...

  1. template

    Code Block
    languagepowershell
    ForEach (

...

  1. $SubjectAlternateName in 

...

  1. $SubjectAlternateNames) {

...

  1.  

...

  1. $CertificateTemplate = '{0}{1}_continue_=

...

  1. "DNS=

...

  1. {2}&

...

  1. "' -f $CertificateTemplate, $NewLine, $SubjectAlternateName }
  2. Run the following commands to add any optional IP Address subject alternate names to the certificate

...

  1. template

    Code Block
    languagepowershell
    ForEach (

...

  1. $CertificateIPAddress in 

...

  1. $CertificateIPAddresses) {

...

  1.  

...

  1. $CertificateTemplate = '{0}{1}_continue_=

...

  1. "IPAddress={2}&"' -f $CertificateTemplate, $NewLine, $CertificateIPAddress }
  2. Run the following commands to trim the certificate template:

    Code Block
    languagepowershell
    $CertificateTemplate = $CertificateTemplate -replace '&"\s*$', '"'
  3. Run the following commands to write the certificate template file:

    Code Block
    languagepowershell
    $Content | Out-File -FilePath $CertificateTemplateFile -Force
  4. Run the following commands

...

  1. to review the certificate

...

  1. template file: 

    Code Block
    languagepowershell
    Get-Content 

...

  1. -Path $CertificateTemplateFile
  2. Run the following commands to create the certificate request file:

    Code Block
    languagepowershell
    certreq -new -f 

...

  1. $CertificateTemplateFile $CertificateRequestFile
  2. Run the following commands to review the certificate request file

    Code Block
    languagepowershell
    Get-Content

...

  1.  -Path $CertificateRequestFile
  2. Run the following commands to retrieve the certificate request file name: 

    Code Block
    languagepowershell
    Get-Item 

...

  1. -Path $CertificateRequestFile

Submit the certificate request to a certificate authority

References