I am using soapui to hit a webservice it's working but im trying to create an implementation with PowerShell, the probleme is im using Invoke-RestMethod to send my request with -certificate and I call my certificat in this way :

$Certificat = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$Certificat.Import($Dir,$password,"DefaultKeySet");
$status = Invoke-RestMethod -Method 'Post'  -Uri $url -Body $body -Certificate $Certificat

the server return 403 error that mean he didnt receive the certificat. my question is there is another method to implement the sending of soap ui call with certificat that require a password.

1 Answers

0
postanote On

Looking at your code again, (I guess I should have scrolled all the way right), you are not specifying a cert.

This...

$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2

... try it this way.

$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")