68

Following the instructions in How to: Configure a Port with an SSL Certificate, I entered this command on the command line (duh):

netsh http add sslcert ipport:10.141.146.227:7001 certhash=5d48e604007b867ae8a69260a4ad318d2c05d8ff appid={EDE3C891-306C-40fe-BAD4-895B236A1CC8}

Output:

The parameter is incorrect.

My certhash thumbprint was taken from the certificate in Certificates (Local Computer)PersonalCertificates folder.

The appid GUID was generated.

What else is wrong that I need to fix to get this to work?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Derrick
  • 831
  • 1
  • 7
  • 9
  • 2
    Useful info on calling external programs from PowerShell "the right way" here...http://edgylogic.com/blog/powershell-and-external-commands-done-right/ – andyb Mar 08 '14 at 21:42
  • 2
    I realized it was all because of my ORDERING! You gotta put `appid` before `certhash`. Its that dumb. – Alexandru Jul 09 '15 at 15:14
  • 9
    For me, the copy-pasted certhash from windows cert manager had some weird character in front - make sure it's just alphanumeric and there is no weird leading chars. – Jacek Gorgoń Sep 24 '15 at 14:32
  • 1
    @JacekGorgoń Yes, me too. Probably a [zero-width space](https://en.wikipedia.org/wiki/Zero-width_space). – Uwe Keim May 18 '17 at 15:58
  • In my case, I got the "incorrect parameter" error because I included the `certhash` and `appid` values inside single quotes (`'`). After removing the single quotes, everything succeeded. – Uwe Keim May 18 '17 at 15:59
  • For me it's was characters in uppercase in the fingerprint... – Wifsimster Jun 19 '18 at 12:25
  • Where does *"thumbprint"* come from (used in several answers)? Isn't it *[fingerprint](https://en.wikipedia.org/wiki/Public_key_fingerprint)*? OK, it is used in the supplied Microsoft reference. [Call the whole thing off](https://www.youtube.com/watch?v=qRrw2hDjnl4&t=25s)? – Peter Mortensen Sep 11 '22 at 22:52

21 Answers21

102

In PowerShell, just type as follows. First get into netsh HTTP mode and then add sslcert. It's worked for me.

netsh

In the netsh session:

http

add sslcert ipport=0.0.0.0:13286 appid='{a5455c78-6489-4e13-b395-47fbdee0e7e6}' certhash=<thumprint without space>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abdul Hakim
  • 1,029
  • 1
  • 7
  • 2
  • @abdul-hakim I am trying to add an sslcert using netsh http from within a powershell ps1 file, but it keeps throwing errors when I specify a GUID value for the appid. Here is my code: $guid = [guid]::NewGuid(); netsh http add sslcert ipport=0.0.0.0:443 certhash=$thumb appid={$guid} – crazyTech Mar 04 '13 at 22:08
  • 11
    If doing fully on PowerShell command line or a ps1 script remember to quote the curley-braces; else PowerShell will be confused. – codingoutloud Mar 08 '14 at 17:19
  • 3
    I realized it was all because of my ORDERING! You gotta put `appid` before `certhash`. Its that dumb. – Alexandru Jul 09 '15 at 15:14
  • 2
    @Alexandru -- and I had to not only do that but also *remove* the quotes. Yes... dumb is right. :P – Lars Kemmann Sep 16 '16 at 02:48
  • @LarsKemmann - quotes are for powershell, no quotes for command shell - see codingoutlouds answer below – CJM May 19 '17 at 11:24
  • 2
    @Alexandru you do not have to put appid before certhash - it is likely that doing that inadvertently fixed a different issue for you. – CJM May 19 '17 at 11:25
  • You have to REMOVE all quotes around appid, otherwise you get "The parameter is incorrect". – AlexPi Dec 22 '20 at 04:48
  • I realized the command posted by OP doesn't work in Powershell but works fine in CMD – mshwf Oct 13 '21 at 12:52
49

Another possible cause for this problem is hidden characters being copied from the Certificate Manager page. If you copy the thumbprint from the details window in Certificates, check for a hidden character at the start (use your arrow keys!). This was the cause for me of the "The Parameter is Incorrect" error message.

Richard
  • 29,854
  • 11
  • 77
  • 120
  • 2
    You're awesome. There is a weird little tick when there is a special character. I noticed it at first but didn't think anything of it. Just removed that special character and SUCCESS. Thanks! – dst3p Jan 25 '17 at 05:15
  • What hidden character is it? A hex dump will usually reveal an [UTF-8](https://en.wikipedia.org/wiki/UTF-8) byte sequence (and thus the Unicode [code point](https://en.wikipedia.org/wiki/Code_point)). One or more Unicode code points can be detected (and search/replaced (deleted)) with regular expressions in most modern text editors, even zero width ones. For example, `\x{00A0}|\x{200B}|\x{200C}|\x{2013}|\x{2014}|\x{201C}|\x{201D}|\x{2212}|\x{00E4}|\x{FFFD}|\x{2217}|\x{200C}|\x{202B}|\x{202A}` to search for the most common ones. – Peter Mortensen Sep 14 '22 at 11:33
  • "200B" is [ZERO WIDTH SPACE](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128). – Peter Mortensen Sep 14 '22 at 11:38
  • [Another answer](https://stackoverflow.com/questions/779228/the-parameter-is-incorrect-error-using-netsh-http-add-sslcert/39526468#39526468) lists "0x3F 0x38", but it isn't clear if that is the actual byte sequence. – Peter Mortensen Sep 14 '22 at 12:16
41

The PowerShell command line and PowerShell scripts in .ps1 files will think curly brackets {...} are PowerShell directives. So quote them. Otherwise, as you have seen, PowerShell will be confused.

So rather than this (which you found fails):

netsh http add sslcert ipport:10.141.146.227:7001 certhash=5d48e604007b867ae8a69260a4ad318d2c05d8ff appid= {EDE3C891-306C-40fe-BAD4-895B236A1CC8}

Do this (note the single quotes):

netsh http add sslcert ipport:10.141.146.227:7001 certhash=5d48e604007b867ae8a69260a4ad318d2c05d8ff appid= '{EDE3C891-306C-40fe-BAD4-895B236A1CC8}'

Here is some information about PowerShell syntax with curley braces:

PowerShell and the hidden art of curly braces and other braces

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
codingoutloud
  • 2,115
  • 19
  • 21
  • 1
    This. You get the same error in cmd if you don't include the curly braces on the guid, or if you don't quote them in powershell. –  Mar 28 '17 at 14:12
  • definitely the single quotes in powershell! – reckface Jan 23 '19 at 09:08
18

Looking at the syntax for the netsh command, I saw this example:

add sslcert ipport=1.1.1.1:443 certhash=0102030405060708090A0B0C0D0E0F1011121314 appid={00112233-4455-6677-8899-AABBCCDDEEFF}

By the looks of it, your problem is that you're doing

ipport:10.141.146.227:7001
      ^

as opposed to

ipport=10.141.146.227:7001
      ^
cmptrgeekken
  • 8,052
  • 3
  • 29
  • 35
14

I faced this problem several times and every time it had a different cause. Here are the causes and exact commands that worked for me.

Here are some causes:

  1. Copy and pasting a certificate thumbprint from the Windows dialog adds a hidden character to your hash. It is not visible in text editors, but you need to remove the character to make it work.

  2. An SSL thumbprint should be available in PersonalCertificates to work with localhost.

  3. It should be 'ipport=', not 'ipport:'

  4. SSL certificate should have a private key. If you are using the certificate management console, make sure that it has a little key icon on the certificate view.

  5. The GUID should be defined in full format: {a10b0420-a21f-45de-a1f8-818b5001145a}, and it should have single quotes in PowerShell: '{a10b0420-a21f-45de-a1f8-818b5001145a}' Thus, the PowerShell format is different from the command line.

  6. SSL certificate should have complete characters with all padding '0's and without any space. You may copy the thumbprint (be careful to remove special hidden characters) and remove spaces, or use 'netsh http show sslcert' to get the value if the certificate is already registered for another address.

What worked for me:

Here is the exact command that worked for me in PowerShell:

netsh http add sslcert ipport=0.0.0.0:20001 certhash=5304c034548b27c72b5e9c14f0c7bdd13e52d760 appid='{a10b0420-a21f-45de-a1f8-818b5001145a}'

And here is the command line statement:

netsh
http add sslcert ipport=0.0.0.0:20001 certhash=5304c034548b27c72b5e9c14f0c7bdd13e52d760 appid={a10b0420-a21f-45de-a1f8-818b5001145a}

More commands to help you avoid related problems:

Use the following command to see current registered certificate. You may find and reuse certhash or your appid from there:

netsh http show sslcert

If the certificate is already registered with similar ip and port, you need to remove it. I found it causes a problem with localhost, 127.0.0.1 and 0.0.0.0. You need to have only 0.0.0.0 registered in your testing environment. Use the following command to remove potential corrupted certificates:

netsh http delete sslcert ipport=0.0.0.0:20001
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mohghaderi
  • 2,520
  • 1
  • 19
  • 12
11

Copying the certificate thumbprint from the Certificate\Details\Thumbprint would prepend the thumbprint value with the bytes '3f38' which, when converted to ANSI were shown as a '?'. This hidden value caused the issue for me.

I pasted the value into Notepad++, chose EncodingConvert to ANSI, and then I manually removed the prepended '?' characters. I would then have a clean thumbprint value to use.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Andreas Presthammer
  • 1,886
  • 2
  • 19
  • 31
  • 3F38 is both the Unicode [code point](https://en.wikipedia.org/wiki/Code_point) and [UTF-16](https://en.wikipedia.org/wiki/UTF-16) byte sequence (UTF-8 0xE3 0xBC 0xB8) for "[CJK UNIFIED IDEOGRAPH-3F38](https://codepoints.net/U+3F38)" (㼸), but given the context that is probably not it. 0x3F is itself question mark ("`?`"). A coincidence? – Peter Mortensen Sep 14 '22 at 12:24
10
  1. Copy the command into Notepad
  2. Save it as ANSI
  3. Close and reopen the file
  4. Remove bogus ? characters
  5. Copy from Notepad to the command prompt and run the command
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
tcb
  • 4,408
  • 5
  • 34
  • 51
5

I was getting this error as well when I was just getting started with HTTP.sys (IIS). After I ran:

netsh http add iplisten ipaddress=0.0.0.0

then the netsh http add sslcert commands started behaving properly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tim Danner
  • 630
  • 8
  • 20
5

In my case the problem is that I am following the Microsoft instructions. I copied the thumbprint from the SSL window. Doing so copies non-printable characters at the beginning of the hash.

Try to paste the thumbprint into Notepad and then press Home and press Delete twice (until the first characters from the thumbprint is deleted) and the readd the character. You can see the character if you copy the thumbprint and paste it into cmd:

Thumbprint with "?"

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
SimSimY
  • 3,616
  • 2
  • 30
  • 35
3

Using the Serial number instead of the Thumbprint for the certhash parameter will cause this error because of the difference in the amount of characters. Padding with 0s will change the error to:

SSL Certificate add failed, Error: 1312

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel N
  • 419
  • 8
  • 20
  • Does this answer the question (not a rhetorical question)? Perhaps expand your answer to make it clear? (But ************* ***without*** *************** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Sep 14 '22 at 12:22
3

This worked for me:

My certhash parameter wasn't fully 20 bytes long. I had to pad it with zeroes in front to get it to work.

So, instead of

certhash=112233445566778899aabbccddeeff00, I had to do this:

certhash=00000000112233445566778899aabbccddeeff00.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

You have ipport: rather than ipport= which is easy to do since you follow that with ip:port.

Also, watch out for the { versus < or (. That has also gotten me in the past.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
GMLewisII
  • 366
  • 1
  • 7
2

Watch out. If you have a DNS name as a binding, use hostnameport instead of ipport:

netsh http delete sslcert hostnameport=domainame.com:443

I had to delete ADFS Proxy Bindings for Office 365 single sign-on.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
joelschmid
  • 828
  • 1
  • 16
  • 32
1

This will work from the PowerShell command line:

$AppId = [Guid]::NewGuid().Guid
$Hash = "209966E2BEDA57E3DB74FD4B1E7266F43EB7B56D"

netsh http add sslcert hostname=localhost:8088 certhash=$Hash appid=`{$AppId`} certstorename my

The important details are to escape each { } with a backtick (`) and not to omit certstorename. Otherwise, netsh raises an error 87.

The variables are just for sake of convenience.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Peter M.
  • 686
  • 1
  • 5
  • 17
1

This is actually a syntax problem of cmd vs PowerShell. Changing the command to

netsh http add sslcert ipport=0.0.0.0:8085 certhash=4da5af739d6745de4e38fea9574cdaa79032ea14 appid="{7BBE87B9-D98F-41D7-B726-FC5E1300ED28}"

will work in both terminals.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

There were a few things I did that I thought made it work after getting the same "The parameter is incorrect." error.

  1. I restarted the machine and did it again. It worked the first time.

  2. I made sure I was in C:\ and issued the command again after restarting didn't work

    I couldn't explain why, but I think that maybe both times, there was something else wrong. Because the third time this happened to me:

  3. I went through the thumbprint of my CA (not the issued server cert) and copied it again from the MMC and it worked.

After this happened, I deleted it again (netsh http delete sslcert ipport=0.0.0.0:) and repeated the process using the thumbprint of the server certificate. The darned thing worked again.

I don't know. Just try going through the same thing I did. Maybe one of these would work. In the end, I suspect that I entered a bogus space or character in the certhash.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Derrick
  • 831
  • 1
  • 7
  • 9
0

The "-"s are not irrelevant.

If your GUID doesn’t look exactly like this, you will get the incorrect parameter error:

{EDE3C891-306C-40fe-BAD4-895B236A1CC8}

vs.

EDE3C891306C40feBAD4895B236A1CC8 -> WRONG
{EDE3C891306C40feBAD4895B236A1CC8} -> WRONG

Also I’m using the GUID for the appid of IIS, not a random one.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Martin Clemens Bloch
  • 1,047
  • 1
  • 12
  • 28
0

I must have ended up mangling the relationship between Visual Studio and IIS Express by deleting the localhost certificate. I was really stuck. The application wouldn't start and nothing I could do seemed to correct this disconnect (which is want brought me to this thread to begin with).

I was finally able to get over the issue by changing the assigned port on the non-SSL URL (launchSettings.json in .NET Core applications) and disabling the Enable SSL checkbox in the project settings and taking a fresh start. I was then able to add my newly created cert with this command: netsh http add sslcert ipport=0.0.0.0:44392 appid={214124cd-d05b-4309-9af9-9caa44b2b74b} certhash=A0ADC1A1002F288CCFA96261F9F352D28C675A90.

Also, note that the appid variable is not a reflection of your Visual Studio project AppID (or at least it doesn't have to be). It's just an arbitrary GUID, according to Scott Hanselmann:

The AppId doesn't really matter, it's just a GUID. This tells HTTP.SYS that we're using that certificate.

This was not obvious to me and made dealing with the parameter is incorrect error that much more obscure.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vinney Kelly
  • 4,975
  • 1
  • 25
  • 31
0

I was trying to add an IP address and port with the hostnameport parameter, so I got this parameter error.

netsh http add sslcert hostnameport="10.0.0.120:443"

Instead of:

netsh http add sslcert ipport="10.0.0.120:443"

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nicolas Leucci
  • 2,829
  • 1
  • 13
  • 12
0

I had a hidden issue that only showed in PowerShell, not on a command prompt.

I had copied a thumbprint from a certificate and removed all spaces in Notepad++, but it still had a hidden character in front.

It looked like this:

.. certhash=dca41243...

It was actually

.. certhash="special char"dca41243...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tommy G.
  • 355
  • 2
  • 9
0

We have put the parameters in quotes (double quotes, not single), and this helped us. This way it worked perfectly.

netsh http add sslcert hostnameport="servername.domain.suffix:8443" certhash="6a1234abcd567edf" appid="{eca1234-a456-5678-abcd-edffg6789}" certstorename="MY"