Last active
August 2, 2022 07:27
-
-
Save gareththered/c8a27007aeb2155a3192a23b1903a721 to your computer and use it in GitHub Desktop.
Display the CA's RequestID after generating a request with Get-Certificate
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
$req = Get-Certificate -Url ldap: -Template ExampleWebServer -SubjectName "CN=Test" -DnsName "test.example.com" -CertStoreLocation Cert:\LocalMachine\My\ | |
$hexSKI=$req.Request.Extensions.SubjectKeyIdentifier | |
# Interrogate CA for request with the above SKI: | |
# Get CA connection string: | |
$CC_DEFAULTCONFIG = 0 | |
$CaConfig = $(New-Object -ComObject CertificateAuthority.Config).GetConfig($CC_DEFAULTCONFIG) | |
$CaView = New-Object -ComObject CertificateAuthority.View.1 | |
$CaView.OpenConnection($caConfig) | |
$CVRC_COLUMN_SCHEMA=0 | |
$colSKI=$CaView.GetColumnIndex($CVRC_COLUMN_SCHEMA,'SubjectKeyIdentifier') | |
$colReq=$CaView.GetColumnIndex($CVRC_COLUMN_SCHEMA,'Request.RequestID') | |
# Filter on SKI = $hexSKI | |
$CVR_SORT_NONE = 0 | |
$CVR_SEEK_EQ = 1 | |
$CaView.SetRestriction($colSKI,$CVR_SEEK_EQ,$CVR_SORT_NONE,$hexSKI) | |
# Define output table | |
$CaView.SetResultColumnCount(1) | |
$CaView.SetResultColumn($colReq) | |
$RowObj= $CAView.OpenView() | |
while ($RowObj.Next() -ne -1) | |
{ | |
$ColObj=$RowObj.EnumCertViewColumn() | |
While ($ColObj.Next() -ne -1) { | |
$ColObj.GetValue(0) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment