Reference: Verify the SHA256 fingerprint of a certificate
When you add or edit a domain in Directory Query a message appears in the Add Domain or Edit Domain panel of the Directory Query workbench that requests that you verify the SHA256 fingerprint of the host certificate before you provide credentials. You can edit and run the following PowerShell script on the server that was entered in LDAP Server in the Add Domain or Edit Domain panel to verify the SHA256 fingerprint of the host certificate. For more information on adding or editing domains, see Add a domain.
$myFingerprint = "B9:4B:42:22:FF:EB:4A:C6:4E:57:5E:26:2A:E6:74:4A:7F:AC:74:67:9A:73:7C:D9:44:A6:6B:9A:F8:F7:FF:F3"
$myCerts = (Get-ChildItem "Cert:\LocalMachine\My")
$sha256 = [System.Security.Cryptography.SHA256]::Create()
ForEach ($Cert in $myCerts) {
$hashBytes = $sha256.ComputeHash($Cert.RawData)
$hashString = -join ($hashBytes | ForEach-Object { $_.ToString("x2") })
if ($hashString -eq ($myFingerprint -replace ":")) {
Write-Output "Found Certficate with matching SHA256 Fingerprint!"
Write-Output "Input SHA256 Fingerprint: $($myFingerprint -replace ":")"
Write-Output "Certificate SHA256 Fingerprint: $($hashString.ToUpper())"
Write-Output "Certificate Details:"
$Cert | FL
}
}
-
Copy the above script and paste it into a text editor.
-
Edit the value of the $myFingerprint variable to match the value that appears in the Add Domain or Edit Domain panel where you are requested to verify the SHA256 fingerprint of the host certificate before you provide credentials.
-
Save the file as Get-CertificateSHA256Fingerprint.ps1.
-
Copy the file to the server that was entered in LDAP Server in the Add Domain or Edit Domain panel.
-
Run the script on the server that was entered in LDAP Server in the Add Domain or Edit Domain panel as an administrator. Right-click the PowerShell icon and select Run as administrator.
The following example shows sample output of the provided script:
JSONFound Certificate with matching SHA256 Fingerprint! Input SHA256 Fingerprint: B94B4222FFEB4AC64E575E262AE6744A7FAC74679A737CD944A66B9AF8F7FFF3 Certificate SHA256 Fingerprint: B94B4222FFEB4AC64E575E262AE6744A7FAC74679A737CD944A66B9AF8F7FFF3 Certificate Details: Subject : CN=2022DC01.lab.example.com Issuer : CN=lab-2022CA01-CA, DC=lab, DC=example, DC=com Thumbprint : EBD63F4C09747C5293D3DF86F0A0D85C69726811 FriendlyName : NotBefore : 10/8/2024 2:30:01 PM NotAfter : 10/8/2025 2:30:01 PM Extensions : {System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid, System.Security.Cryptography.Oid...} -
Ensure that the Input SHA256 Fingerprint and Certificate SHA256 Fingerprint values match to verify the SHA256 fingerprint of the certificate.
An alternative to running the provided script to verify the SHA256 fingerprint of the certificate is to issue the following commands on the server that was entered in LDAP Server in the Add Domain or Edit Domain panel:
certutil -store my <serialnumber> <outputfile>
certutil -hashfile <outputfile> sha256
In the commands, <serialnumber> corresponds to the serial number displayed in the Add Domain or Edit Domain panel and <outputfile> corresponds to a file to which you want to write the results.
For example:
PS C:\Users\Administrator.DEV> certutil -store my 123456789xzy output.cer
My "Personal"
================ Certificate 1 ================
Serial Number: 330000001edf2612e59ed68e9300000000001e
Issuer: CN=lab-2022CA01-CA, DC=lab, DC=example, DC=com
NotBefore: 10/8/2024 12:27 PM
NotAfter: 10/8/2025 12:27 PM
Subject: CN=2022DC02.dev.lab.example.com
Certificate Template Name (Certificate Type): DomainController
Non-root Certificate
Template: DomainController, Domain Controller
Cert Hash(sha1): d2ad6c2cb9a45b7997082e289e1abe7e7a20c2b2
Key Container = d52364ec8ae4afabdf2705f81d51136b_bffa39fb-090b-42c0-b90a-8ab4432a94da
Simple container name: te-DomainController-cc6b99e0-5d20-403a-9d8c-e964e2834660
Provider = Microsoft RSA SChannel Cryptographic Provider
Private key is NOT exportable
Encryption test passed
CertUtil: -store command completed successfully.
Calculate the SHA256 hash of the certificate to verify the SHA256 fingerprint of the certificate:
PS C:\Users\Administrator.DEV> certutil -hashfile output.cer sha256
SHA256 hash of output.cer:
8be7eb2635927e413ac348f0b475cfd95fd01fd057c3cbcc8ecbe1ededb2a626
CertUtil: -hashfile command completed successfully.
The SHA256 hash of the output should correspond with the value of the SHA256 fingerprint of the certificate that appears in the Add Domain or Edit Domain panel.