summaryrefslogtreecommitdiff
path: root/examples/scripts
diff options
context:
space:
mode:
authorMatt Davis <nitzmahone@users.noreply.github.com>2017-02-13 01:16:23 -0800
committerTrond Hindenes <trond@hindenes.com>2017-02-13 10:16:23 +0100
commitba353b0f8fa5ddf43302c47acc67f8c30023c260 (patch)
tree2e507492a9508531658c8a399459be4f792077c9 /examples/scripts
parenta6cb3774207104d8817effe7b96b5f5f4a07358e (diff)
downloadansible-ba353b0f8fa5ddf43302c47acc67f8c30023c260.tar.gz
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.
Diffstat (limited to 'examples/scripts')
-rw-r--r--examples/scripts/ConfigureRemotingForAnsible.ps19
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/scripts/ConfigureRemotingForAnsible.ps1 b/examples/scripts/ConfigureRemotingForAnsible.ps1
index be4c8129d9..6ec31b8579 100644
--- a/examples/scripts/ConfigureRemotingForAnsible.ps1
+++ b/examples/scripts/ConfigureRemotingForAnsible.ps1
@@ -112,10 +112,11 @@ Function New-LegacySelfSignedCert
$certdata = $enrollment.CreateRequest(0)
$enrollment.InstallResponse(2, $certdata, 0, "")
- # Return the thumbprint of the last installed certificate;
- # This is needed for the new HTTPS WinRM listerner we're
- # going to create further down.
- Get-ChildItem "Cert:\LocalMachine\my"| Sort-Object NotBefore -Descending | Select -First 1 | Select -Expand Thumbprint
+ # extract/return the thumbprint from the generated cert
+ $parsed_cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
+ $parsed_cert.Import([System.Text.Encoding]::UTF8.GetBytes($certdata))
+
+ return $parsed_cert.Thumbprint
}
# Setup error handling.