Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Accessing a web service using certificate authentication

$
0
0

I have a web service that requires certificate authentication, and I would like to call it using PowerShell.

If I export my certificate to a pfx file, I can access the service with this code:

$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 "C:\tmp\cert.pfx", "ThePassword"
$proxy = New-WebServiceProxy "https://xxx/service.asmx"
$proxy.ClientCertificates.Add($certificate)
$proxy.SomeMethod()

However, to do this, I must also allow access to the service with anonymous authentication, and verify in the actual calls if the user is authenticated.

Since Get-Credential allows me to select a certificate, I hoped I could do something like this:

$proxy = New-WebServiceProxy "https://xxx/service.asmx" -Credential $(Get-Credential)
$proxy.SomeMethod()

But this does not seem to work, and it behaves like the proxy is not using any credentials.

Is it possible to use a certificate in a call to New-WebServiceProxy?


Paolo Tedesco - http://cern.ch/idm


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>