有谁知道如何使 SvcUtil.exe 连接到使用 TLS 1.2 的端点?我正在使用 .Net Framework 4.6.1 版。
当我使用 VS 2017 连接时,我可以看到使用 Fiddler 请求是通过使用 ClientHello 握手的隧道建立的,该握手使用 Version: 3.3 (TLS/1.2)
.但是,当我直接使用 svcutil.exe 时,它会尝试使用尝试使用 Version: 3.1 (TLS/1.0)
的 ClientHello 握手建立隧道的请求。并随后失败。
我希望我可以在 SvcUtil.exe.config 中设置如下内容:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<generatePublisherEvidence enabled="false" />
</runtime>
<system.net>
<settings>
<servicepointmanager securityprotocol="tls12">
</servicepointmanager>
</settings>
</system.net>
</configuration>
这将反射(reflect)等效的 SecurityProtocol ServicePointManager 类上的属性。但是,这只会产生以下错误:
Unrecognized element 'servicepointmanager'.
我使用 SvcUtil 如下:
SvcUtil https://myserver/myservice/mex
最佳答案
我尝试使用 documentation 中推荐的方式也一样,但我无法让它工作。所以我假设它使用了一些自定义配置部分。相反,我目前正在使用以下控制台应用程序来加载 svcutil.exe
并手动设置所需的属性:
using System.Net;
using System.Reflection;
namespace SvcUtil2
{
class Program
{
static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Your SvcUtil path here
var svcUtilPath = @"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools\SvcUtil.exe";
var svcUtilAssembly = Assembly.LoadFile(svcUtilPath);
svcUtilAssembly.EntryPoint.Invoke(null, new object[] { args });
}
}
}
我知道它可能无法回答您的实际问题,但我希望它仍然有用。
关于wcf - 如何使用带有 Tls 1.2 的端点的 Svcutil.exe 获取元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46707472/