Search…
Intermediate Certificate
SCEPman Enterprise Edition only
If you want to use another Root CA as primary authority, you can create an intermediate CA certificate. You can create the correct certificate direct in Azure Key Vault and download the CSR for signing with your Root CA. The signed request can be uploaded and merged into the Azure Key Vault.

Key Vault Access Policy

You need to grant and Azure AD App and your user account access to the Azure Key Vault. Note that the Azure AD App is different to the Azure App Service! In a SCEPman installation without Intermediate CA, you usually do not have to grant permission to the Azure AD App, but here it is required!
  1. 1.
    Navigate to your Azure Key Vault in the Azure Portal
  2. 2.
    Click on Access policies in the left navigation pane.
  3. 3.
    Click on Add Access Policy
  1. 1.
    Click Configure from template (optional) and choose Certificate Management.
  2. 2.
    Now you must select a principal by clicking on None selected and search for your Azure AD App Registration.
  3. 3.
    To close the dialog press Select and then press Add.
Now repeat this for your own user account:
  1. 1.
    Click on Add Access Policy again.
  2. 2.
    Again, click Configure from template (optional) and choose Certificate Management.
  3. 3.
    Select a principal by clicking on None selected. But this time, search for your own administrative user account.
  4. 4.
    Close the dialog with Select and Add.
  1. 1.
    To save your new access policies you must click on Save in the upper left corner of the window.
After saving this access policies successfully, your Azure AD app is permitted to create a CSR and your user account is permitted to upload the certificate.

Creating Intermediate CA Certificate via API

You must create the certificate via the Key Vault API. This is because not all flags and features are available via UI and native PowerShell CMDlets. Add values for the six parameters TenantID, ApplicationID, ApplicationKey, KeyVaultName, NewCertName, and CompanyName to the following PowerShell script. Create a new Application Secret to use as ApplicationKey in your Azure AD App registration with minimum lifetime.
1
###################################################################################
2
# #
3
# PowerShell Script to generate a CSR for a SCEPman Intermediate CA certificate #
4
# #
5
###################################################################################
6
​
7
# Version: 2021-07-09
8
# Authors: Aaron Navratil and GKGAB contributors
9
# License: Unlicense (https://unlicense.org/)
10
# Source: https://docs.scepman.com/scepman-configuration/optional/intermediate-certificate
11
​
12
$config = @{
13
TenantID = "" # <GUID> of your Azure AD Tenant
14
ApplicationID = "" # <GUID> -> the Application (Client) ID of your Azure App Registration
15
ApplicationKey = "" # Client secret from you Azure App Registration
16
KeyVaultName = "" # Name of your Azure Key Vault ressource
17
NewCertName = "" # Name of your new Intermediate CA certificate. Use Letters, Numbers, and/or spaces.
18
CompanyName = "" # Your Company Name. Use Letters, Numbers, and/or spaces.
19
}
20
​
21
$body = [ordered]@{
22
grant_type = "client_credentials"
23
client_id = $config.ApplicationID
24
client_secret = $config.ApplicationKey
25
scope = "https://vault.azure.net/.default"
26
}
27
​
28
$TokenResponse = Invoke-RestMethod https://login.microsoftonline.com/$($config.TenantID)/oauth2/v2.0/token -Method Post -Body $body -UseBasicParsing
29
​
30
$AuthHeader = @{Authorization = $TokenResponse.token_type + " " + $TokenResponse.access_token}
31
​
32
$CertBody = @"
33
{
34
"policy": {
35
"key_props": {
36
"exportable": true,
37
"kty": "RSA",
38
"key_size": 2048,
39
"reuse_key": false
40
},
41
"secret_props": {
42
"contentType": "application/x-pkcs12"
43
},
44
"x509_props": {
45
"subject": "O=$($config.CompanyName), OU=$($config.TenantID), CN=$($config.NewCertName)",
46
"ekus": [],
47
"key_usage": [
48
"cRLSign",
49
"digitalSignature",
50
"keyCertSign",
51
"keyEncipherment"
52
],
53
"validity_months": 120,
54
"basic_constraints": {
55
"ca": true
56
}
57
},
58
"lifetime_actions": [
59
{
60
"trigger": {
61
"lifetime_percentage": 80
62
},
63
"action": {
64
"action_type": "EmailContacts"
65
}
66
}
67
],
68
"issuer": {
69
"name": "Unknown",
70
"cert_transparency": false
71
}
72
}
73
}
74
"@
75
​
76
# https://docs.microsoft.com/en-us/rest/api/keyvault/create-certificate/create-certificate#uri-parameters
77
$CertReq = Invoke-RestMethod https://$($config.KeyVaultName).vault.azure.net/certificates/$($config.NewCertName -replace "[^A-Za-z0-9-]", "-")/create?api-version=7.2 -Method Post -Body $CertBody -ContentType "application/json" -Headers $AuthHeader -UseBasicParsing
78
​
79
$CSRText = @"
80
-----BEGIN CERTIFICATE REQUEST-----
81
$([regex]::Matches($CertReq.csr, "[^\s]{1,64}").value -join "`n")
82
-----END CERTIFICATE REQUEST-----
83
"@
84
​
85
$CSRText
86
​
87
Write-Host -ForegroundColor Cyan @"
88
After Signing the CSR use the values of:
89
​
90
$($config.NewCertName -replace '[^A-Za-z0-9]', "-") in AppConfig:KeyVaultConfig:RootCertificateConfig:CertificateName
91
and
92
CN=$($config.NewCertName), OU=$($config.TenantID), O=$($config.CompanyName) in AppConfig:KeyVaultConfig:RootCertificateConfig:Subject
93
"@
Copied!

Issue the Intermediate CA Certificate

Now, submit your CSR to your Root CA and retrieve your issued Intermediate CA Certificate. Save the certificate on disk ((.cer)), so in the next step, you can upload and merge it with the private key in Azure Key Vault.

Special Steps for an ADCS Enterprise Root CA

If you are using Active Directory Certificate Services as an AD-integrated Root CA and hence must choose a Certificate Template, it must include the following Key Usages: "CRLSign", "DigitalSignature", "KeyEncipherment", and "KeyCertSign". KeyEncipherment is missing in the default template "Subordinate Certificate Authority", and furthermore cannot be selected on new templates. Please see below for a solution if you run into this problem. This does not apply to Stand-alone Root CAs, aka Offline Root CAs, as they take the Key Usages correctly from the CSR.

Outline

You can Duplicate the SubCA Template or use as it is as required. Then you just issue a certificate with the template based on the CSR. This certificate will have the wrong Key Usage (0x86). Afterwards, you re-sign the certificate with an adapted Key Usage extension using certutil -sign.

Step by step

  1. 1.
    Request and issue a SubCA certificate.
  2. 2.
    Export the new SubCA certificate to a file (e.g. c:\temp\SubCA.cer) on the Enterprise CA.
  3. 3.
    Create a file "extfile.txt" with the contents shown below to the Enterprise CA (e.g. c:\temp\extfile.txt).
  4. 4.
    Start command line and excecute: certutil -sign "c:\temp\SubCA.cer" "c:\temp\SubCAwithKeyEncipher.cer" @c:\temp\extfile.txt
  5. 5.
    The certificate SubCAwithKeyEncipher.cer now contains the requested key usage (0xA6). The thumbprint (signature) has changed, but the serial number hasn't.
  6. 6.
    The list of issued certificates in ADCS contains the old certificate. Since the serial number hasn't changed, you can manage the new certificate using the old handle, e.g. revoking the old certificate will revoke the new certificate. If you dislike this, you can delete the old certificate entry using certutil -deleterow and then import the new certificate using certutil -importcert.

extfile.txt

1
[Extensions]
2
2.5.29.15=AwIBpg==
3
Critical=2.5.29.15
Copied!

Upload the Intermediate CA Certificate

  1. 1.
    In Azure Key Vault, click on your certificate and press Certificate Operation
  2. 2.
    **Now you can see the options Download CSR and Merge Signed Request**
  1. 1.
    Click on Merge Signed Request and upload your Intermediate CA Certificate. After you have uploaded the signed request, you can see the valid certificate in your Azure Key Vault in the area Completed

Update Azure App Service Settings

The last step is to update the Azure App Service which runs the SCEPman with the new certificate information.
  1. 1.
    Navigate to you Azure App Service
  2. 2.
    Click on Configuration in the left navigation pane
  3. 3.
    In Application settings you must edit the following settings:
AppConfig:KeyVaultConfig:RootCertificateConfig:CertificateName AppConfig:KeyVaultConfig:RootCertificateConfig:Subject
  1. 1.
    As value you must insert your new certificate name and the new subject name.
  2. 2.
    To complete this step, you must click on Save in the upper left part.
Please restart the Azure App Service and then navigate to your SCEPman URL. On the SCEPman Status page you can see the new configuration and download the new intermediate CA certificate to deploy this via Endpoint Manager.
Please check whether the CA certificate fulfills all requirement by visiting your SCEPman Homepage. Check what the homepage says next to "CA Suitability". If, for example, it says CA Certificate is missing Key Usage "Key Encipherment"., you should go back to step Issue the Intermediate CA Certificate and correct the certificate issuance.

Intermediate CAs and Intune SCEP Profiles

The SCEP Configuration Profiles in Intune must reference the Root CA, not the Intermediate CA. Otherwise, the configuration profile fails on some plattforms.