“参数不正确” 使用“netsh http add sslcert”时出错

发布于 2024-07-17 23:14:11 字数 635 浏览 11 评论 0 原文

按照如何:使用 SSL 证书配置端口,我在命令行上输入了此命令(废话):

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

输出:

The parameter is incorrect.

我的 certhash 指纹是从证书(本地计算机) 中的证书中获取的 → 个人证书文件夹

appid GUID 已生成。

我还需要修复哪些问题才能使其正常工作?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(22

何时共饮酒 2024-07-24 23:14:11

PowerShell 中,只需键入以下内容。 首先进入netsh HTTP模式,然后添加sslcert。 这对我有用。

netsh

netsh 会话中:

http

add sslcert ipport=0.0.0.0:13286 appid='{a5455c78-6489-4e13-b395-47fbdee0e7e6}' certhash=<thumprint without space>

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>
岁月如刀 2024-07-24 23:14:11

导致此问题的另一个可能原因是从证书管理器页面复制隐藏字符。 如果您从“证书”中的详细信息窗口复制指纹,请检查开头是否有隐藏字符(使用箭头键!)。 这就是我出现“参数不正确”错误消息的原因。

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.

×眷恋的温暖 2024-07-24 23:14:11

.ps1 文件中的 PowerShell 命令行和 PowerShell 脚本会认为大括号 {...} 是 PowerShell 指令。 所以引用他们的话。 否则,正如您所见,PowerShell 将会感到困惑。

因此,而不是这样做(您发现失败):

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

执行此操作(注意单引号):

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

以下是有关带大括号的 PowerShell 语法的一些信息:

PowerShell 以及大括号和其他大括号的隐藏艺术

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

放我走吧 2024-07-24 23:14:11

查看 netsh 命令的语法,我看到了这个示例:

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

从表面上看,您的问题是您正在做的事情

ipport:10.141.146.227:7001
      ^

ipport=10.141.146.227:7001
      ^

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
      ^
一桥轻雨一伞开 2024-07-24 23:14:11

我多次遇到这个问题,每次都有不同的原因。 以下是对我有用的原因和确切命令。

原因如下:

  1. 从 Windows 对话框中复制并粘贴证书指纹会向您的哈希值添加隐藏字符。 它在文本编辑器中不可见,但您需要删除该字符才能使其工作。

  2. SSL 指纹应在个人证书中可用,以便与本地主机一起使用。

  3. 应该是“ipport=”,而不是“ipport:”

  4. SSL 证书应该有私钥。 如果您使用证书管理控制台,请确保它在证书视图上有一个小钥匙图标。

  5. GUID 应以完整格式定义:{a10b0420-a21f-45de-a1f8-818b5001145a},并且在 PowerShell 中应包含单引号:'{a10b0420-a21f-45de-a1f8-818b5001145a}' 因此,PowerShell格式与命令行不同。

  6. SSL 证书应具有完整的字符,所有字符都填充为“0”且不含任何空格。 您可以复制指纹(注意删除特殊隐藏字符)并删除空格,或者如果证书已注册到另一个地址,则使用“netsh http show sslcert”来获取值。

什么对我有用:

这是在 PowerShell 中对我有用的确切命令:

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

这是命令行语句:

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

可帮助您避免相关问题的更多命令:

使用以下命令查看当前注册的证书。 您可以从那里找到并重用 certhash 或您的 appid:

netsh http show sslcert

如果证书已使用类似的 ip 和端口注册,则需要将其删除。 我发现它会导致 localhost127.0 出现问题.0.10.0.0.0。 您只需在测试环境中注册0.0.0.0。 使用以下命令删除潜在损坏的证书:

netsh http delete sslcert ipport=0.0.0.0:20001

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
执妄 2024-07-24 23:14:11

Certificate\Details\Thumbprint复制证书指纹会在指纹值前面添加字节“3f38”,当转换为 ANSI 时,该值将显示为“?”。 这个隐藏的价值给我带来了问题。

我将值粘贴到 Notepad++ 中,选择编码转换为 ANSI,然后我手动删除了前面的“?” 人物。 然后我将有一个干净指纹值可供使用。

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.

诗化ㄋ丶相逢 2024-07-24 23:14:11
  1. 将命令复制到 记事本
  2. 保存为 ANSI
  3. 关闭并重新打开文件
  4. 删除伪造文件? 字符
  5. 从记事本复制到命令提示符并运行命令
  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
木槿暧夏七纪年 2024-07-24 23:14:11

当我刚刚开始使用 HTTP.sys (IIS)。 我运行后:

netsh http add iplisten ipaddress=0.0.0.0

然后 netsh http add sslcert 命令开始正常运行。

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.

日裸衫吸 2024-07-24 23:14:11

就我而言,问题是我遵循了 Microsoft 的说明。 我从 SSL 窗口复制了指纹。 这样做会复制哈希开头的不可打印字符。

尝试将指纹粘贴到记事本中,然后按Home 并按 Delete 两次(直到指纹被删除)并重新添加字符。 如果复制指纹并将其粘贴到 cmd 中,您就可以看到该字符:

带有“?”的指纹

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 "?"

风铃鹿 2024-07-24 23:14:11

这对我有用:

我的 certhash 参数的长度不完全是 20 个字节。 我必须在前面填充零才能使其正常工作。

因此,

我必须这样做:

certhash=00000000112233445566778899aabbccddeeff00,而不是 certhash=112233445566778899aabbccddeeff00

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.

末が日狂欢 2024-07-24 23:14:11

小心。 如果您有 DNS 名称作为绑定,请使用 hostnameport 而不是 ipport

netsh http delete sslcert hostnameport=domainame.com:443

我必须删除 Office 365 单点登录- 上

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.

剩余の解释 2024-07-24 23:14:11

使用序列号而不是指纹作为 certhash 参数将导致此错误,因为字符数存在差异。 用 0 填充会将错误更改为:

SSL 证书添加失败,错误:1312

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

流年里的时光 2024-07-24 23:14:11

您使用的是ipport:,而不是ipport=,这很容易做到,因为您可以使用ip:port

另外,请注意 {<(。这也让我过去感到困惑。

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.

夏雨凉 2024-07-24 23:14:11

在得到相同的“参数不正确”后,我做了一些事情,我认为它可以工作。 错误。

  1. 我重新启动机器并再次执行此操作。 第一次就成功了。

  2. 我确定我在 C:\ 并在重新启动后再次发出该命令不起作用

    我无法解释原因,但我认为也许两次都有其他问题。 因为这已经是我第三次发生了:

  3. 我查看了我的 CA 的指纹 (不是颁发的服务器证书)并再次从 MMC 复制它,它起作用了。

发生这种情况后,我再次删除它(netsh http delete sslcert ipport=0.0.0.0:)并使用服务器证书的指纹重复该过程。 那该死的东西又起作用了。

我不知道。 尝试经历我做过的同样的事情。 也许其中之一会起作用。 最后,我怀疑我在 certhash 中输入了虚假的空格或字符。

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.

飘然心甜 2024-07-24 23:14:11

这其实是cmd vs PowerShell的语法问题。 将命令更改为

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

将在两个终端中运行。

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.

风吹雪碎 2024-07-24 23:14:11

这将在 PowerShell 命令行中起作用:

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

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

重要的细节是使用反引号 (`) 转义每个 { },并且不要省略 certstorename。 否则,netsh 会引发错误 87。

这些变量只是为了方便起见。

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.

来日方长 2024-07-24 23:14:11

我有一个隐藏的问题,该问题仅显示在 PowerShell 中,而不显示在命令提示符上。

我从证书中复制了指纹,并删除了 Notepad++ 中的所有空格,但是它的前面仍然有一个隐藏的字符。

它看起来像这样:

.. certhash=dca41243...

实际上是

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

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...

风渺 2024-07-24 23:14:11

我试图使用 hostnameport 参数添加 IP 地址 和端口,所以我得到了这个参数错误。

netsh http add sslcert hostnameport="10.0.0.120:443"

而不是:

netsh http add sslcert ipport="10.0.0.120:443"

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"

怀里藏娇 2024-07-24 23:14:11

我一定最终破坏了 Visual StudioIIS Express 通过删除 localhost 证书。 我真的被困住了。 应用程序无法启动,我似乎无能为力来纠正这种断开连接(这就是让我开始进入这个线程的原因)。

我终于能够通过更改非 SSL URL 上分配的端口(.NET Core 应用程序)并禁用项目设置中的启用 SSL 复选框并重新开始。 然后,我可以使用以下命令添加新创建的证书: netsh http add sslcert ipport=0.0.0.0:44392 appid={214124cd-d05b-4309-9af9-9caa44b2b74b} certhash=A0ADC1A1002F288CCFA96261F9F352D28C675A90

另请注意,appid 变量并不反映您的 Visual Studio 项目 AppID(或者至少不必如此)。 它只是一个任意的 GUID,根据 Scott Hanselmann

AppId 并不重要,它只是一个 GUID。 这告诉 HTTP.SYS 我们正在使用该证书。

这对我来说并不明显,并且使得处理参数不正确错误变得更加模糊。

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.

半世蒼涼 2024-07-24 23:14:11

“-”并非无关紧要。

如果您的 GUID 与此不完全一样,您将收到不正确的参数错误:

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

vs.

EDE3C891306C40feBAD4895B236A1CC8 -> 错误
{EDE3C891306C40feBAD4895B236A1CC8} -> 错误

另外,我正在使用 IIS 的 appid 的 GUID,而不是随机的。

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.

此生挚爱伱 2024-07-24 23:14:11

我们将参数放在引号中(双引号,而不是单引号),这对我们很有帮助。 这样就完美运行了。

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

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"
囚你心 2024-07-24 23:14:11

就我而言,我将我的变量连接为 hostnameport 不正确,并且在从 PowerShell 运行时,该值周围的转义字符最终为我解决了问题。

netsh http add sslcert hostnameport=`"$siteName`:443`" certhash=$thumbprint certstorename=MY appid=$guid

In my case I was concatenating my variable for hostnameport incorrect and escaping characters around this value worked out for me in the end when running from PowerShell.

netsh http add sslcert hostnameport=`"$siteName`:443`" certhash=$thumbprint certstorename=MY appid=$guid
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文