c# - wcf 为什么我看不到我的 https 站点

标签 c# wcf ssl

我创建了一个简单的网络服务。 然后我创建了一个控制台主机,它必须通过 https url 托管服务..

这是我的配置:

     <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service behaviorConfiguration="mexBehaviour" name="NuriServiceLibrary.NuriService">
                <clear />
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfig"
                    contract="NuriServiceLibrary.iNuriService" listenUriMode="Explicit" />
                <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
                <host>
                    <baseAddresses>
                        <add baseAddress="https://192.168.....:8001/SecureConsole" />
                    </baseAddresses>
                </host>
            </service>
        </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="mexBehaviour">
            <serviceMetadata  httpGetEnabled="false" httpsGetEnabled="true"  />
          </behavior>
        </serviceBehaviors>
      </behaviors>

      <bindings>
        <basicHttpBinding>
          <binding name="basicHttpBindingConfig">
            <security mode="Transport">
              <transport clientCredentialType="None" />
            </security>
          </binding>
        </basicHttpBinding>
      </bindings>
    </system.serviceModel>
</configuration>

这是我的 program.cs:

    static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof(NuriService));
            host.Open();
            foreach (Uri address in host.BaseAddresses)
            {
                Console.WriteLine("Listening on " + address);
            }
            Console.WriteLine("Press <Enter> to terminate Host.\n\n");
            Console.ReadLine();

            host.Close();
        }

我通过以下方式创建了证书: 1. makecert.exe -sr LocalMachine -ss My -n CN=192.168..... -sky exchange -sk -pe 2.netsh http add sslcert ipport=192.168....:8001 certhash=(故意留下) appid={(故意留下)}

但问题是,我看不到我的 https 网页...我看到这个网站不可用... 有人有想法吗?

最佳答案

尝试添加 HttpsGetUrl属性为 <serviceMetadata>并指定一个空字符串:

<serviceBehaviors>
    <behavior name="mexBehaviour">
        <serviceMetadata  httpGetEnabled="false"
                          httpsGetEnabled="true"
                          httpsGetUrl="" />
    </behavior>
</serviceBehaviors>

这将使服务元数据通过服务的 base address 可用。 :

https://localhost:8001/SecureConsole?wsdl 

关于c# - wcf 为什么我看不到我的 https 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684107/

相关文章:

c# - Roguelike 的 List<string> 中的 X 和 Y 轴索引

c# - WCF 服务,我可以在浏览器中查看输出吗?

java - 无需 ssl 重新协商的 ssl 客户端身份验证

redirect - Nginx proxy_pass 重定向到错误的域

c# - 需要一些解释这是什么 C# 奇怪的语法

c# - 使用 control.BackgroundImage = Image.FromStream(memStream) 时出现内存不足异常;

WCF svc 托管 IIS 7 自签名证书的使用

Python 请求在某些站点上抛出 SSL 错误

c# - 在 IIS 7 中以编程方式为自定义身份应用程序池设置用户帐户

wcf - 检查权限的最佳位置在哪里?