# winrm, HTTPS, wildcard certificate

**URL:** <https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929>\
**Category:** PowerShell Help\
**Created:** [September 28, 2015, 3:43am UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929 "2015-09-28T03:43:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedro-casalinho](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@pedro-casalinho](https://forums.powershell.org/u/pedro-casalinho)\
**Post date:** [September 28, 2015, 3:43am UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929/1 "2015-09-28T03:43:55Z")

</div>

Can we use a wildcard certificate to configure WinRM with HTTPS?

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [September 28, 2015, 3:55am UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929/2 "2015-09-28T03:55:54Z")

</div>

Technically, yes.

Keep in mind that the point of SSL with WinRM isn’t to provide encryption - that’s a side effect. The main point is to uniquely and positively identify the server, thus making spoofing more difficult. You just have to decide if a wildcard certificate meets that business need in your organization.

---

<div class="post-metadata">

**Author:** ![pedro-casalinho](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@pedro-casalinho](https://forums.powershell.org/u/pedro-casalinho)\
**Post date:** [September 28, 2015, 4:12am UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929/3 "2015-09-28T04:12:52Z")

</div>

The thing is  
`winrm create winrm/config/listener?Address=+Transport=HTTPS @{Hostname=".myDomain.local";CertificateThumbprint=“‎52D1x0x6x0x2xCx8x5x2x4x1x3x7xFx1x9x4x0x6”}`  
this happens: winrm : Error: Invalid use of command line. Type “winrm -?” for help.

What I’ve found is that de @hash part must be inside single quotes.  
`winrm create winrm/config/Listener?Address=+Transport=HTTPS ‘@{Port=“8888”}’ #Works!
winrm create winrm/config/Listener?Address=+Transport=HTTPS @{Port=“8888”} #Doesn’t!`

I know this because I have a _no_ wildcard certificate and I can create a HTTPS listener without problems with default configuration, changing the port number.

If I use the single quotes ‘@{…}’ nothing happens! No HTTPs listener is created.  
the subject of my wildcard certificate is `E = blablabla@mail.pt
CN = *.mydomain.local, OU = aaaaaa, O = AA, L = Lisbon, S = Lisbon, C = PT`  
and it’s valid…

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [September 28, 2015, 4:21am UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929/4 "2015-09-28T04:21:52Z")

</div>

Hmm. I’ll have to research that a bit when I get some time. It’s possible WinRM is rejecting the certificate because it really is _intended_ to uniquely identify the server. A wildcard certificate doesn’t do identity the same way as a non-wildcard cert, obviously.

The single/double quotes behavior is expected. Winrm.exe isn’t a PowerShell command; it’s running under Cmd.exe, so it kind of has its own rules.

---

<div class="post-metadata">

**Author:** ![pedro-casalinho](https://avatars.discourse-cdn.com/v4/letter/p/4491bb/32.png) [@pedro-casalinho](https://forums.powershell.org/u/pedro-casalinho)\
**Post date:** [September 28, 2015, 8:17pm UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929/5 "2015-09-28T20:17:33Z")

</div>

Ok! “…isn’t a PowerShell command” This is the Key! 🙂

So, either run it in the command prompt  
`winrm create winrm/config/listener?Address=+Transport=HTTPS @{Hostname=".myDomain.local"; CertificateThumbprint=“xxx”}`  
or inside PowerShell

```
#region Any of these do NOT work!
winrm create winrm/config/listener?Address=*+Transport=HTTPS @{Hostname="*.myDomain.local"; CertificateThumbprint="‎xxx"}
winrm create winrm/config/listener?Address=*+Transport=HTTPS '@{Hostname="*.myDomain.local"; CertificateThumbprint="‎xxx"}'
$_params = '@{Hostname="*.myDomain.local"; CertificateThumbprint="‎xxx"}'
winrm create winrm/config/listener?Address=*+Transport=HTTPS $_params
#endregion Does NOT work!

#region These both WORK!
#Using literal string
$_params = @"
@{Hostname="*.myDomain.local"; CertificateThumbprint="xxx"}
"@
winrm create winrm/config/listener?Address=*+Transport=HTTPS $_params
#---
#Escaping @ { } " WORKS!
winrm create winrm/config/listener?Address=*+Transport=HTTPS `@`{Hostname=`"*.myDomain.local`"`; CertificateThumbprint=`"xxx`"`}
#endregion These both WORK!
```

Thanks!  
IT WORKS!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:44pm UTC](https://forums.powershell.org/t/winrm-https-wildcard-certificate/4929/6 "2024-05-16T20:44:45Z")

</div>

Closed on May 16, 2024, 8:44pm UTC


