fix ambiguous cert selection in WinRM enable script (#21263)

Rather than trying to guess which cert we just generated,   parse the generated cert data and extract the thumbprint directly.
reviewable/pr21331/r1
Matt Davis 8 years ago committed by Trond Hindenes
parent a6cb377420
commit ba353b0f8f

@ -112,10 +112,11 @@ Function New-LegacySelfSignedCert
$certdata = $enrollment.CreateRequest(0) $certdata = $enrollment.CreateRequest(0)
$enrollment.InstallResponse(2, $certdata, 0, "") $enrollment.InstallResponse(2, $certdata, 0, "")
# Return the thumbprint of the last installed certificate; # extract/return the thumbprint from the generated cert
# This is needed for the new HTTPS WinRM listerner we're $parsed_cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
# going to create further down. $parsed_cert.Import([System.Text.Encoding]::UTF8.GetBytes($certdata))
Get-ChildItem "Cert:\LocalMachine\my"| Sort-Object NotBefore -Descending | Select -First 1 | Select -Expand Thumbprint
return $parsed_cert.Thumbprint
} }
# Setup error handling. # Setup error handling.

Loading…
Cancel
Save