我正在尝试访问 https://geocoder.cit.api.here.com在单声道上使用 .NET (F#)。我正在使用 FSharp.Data
中的 Http
帮助器,代码如下:
let baseUrl = "https://geocoder.cit.api.here.com/6.2/geocode.json?searchtext=1701%20McFarland%20Blvd%20E%20Tuscaloosa%09%20AL&app_id=<Some app id>&app_code=<Some app code>"
let res = Http.RequestString(baseUrl)
在单声道版本 4.6.2 的 OSX Sierra (10.12.2) 上为我运行此程序会产生 SecureChannelFailure
。我该如何解决这个问题?我试过 mozroots --import --ask-remove
但没有用。 ~/.config/.mono/certs/Trust
中有证书。
我什至试图绕过检查,因为我只是在调查 API,但这也不起作用。我试图绕过它的方式是:
let callback = Security.RemoteCertificateValidationCallback(fun _ _ _ _ -> true)
ServicePointManager.ServerCertificateValidationCallback <- callback
最佳答案
使用 Mono 4.8+ 您可以分配环境变量 MONO_TLS_PROVIDER
至 btls
在运行基于 CIL 之前 .exe
:
export MONO_TLS_PROVIDER=btls
mono someFSharpAssembly.exe
通过 Xamarin Studio/Visual Studio for Mac 将其分配给运行配置:
如果你得到一个HttpRequestException
:
Error: TrustFailure (Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED) ---> Mono.Btls.MonoBtlsException
It means that you do not have the certificates in the new format. Run the tool “btls-cert-sync” to convert your existing root certificates into the new file format. If “btls-cert-sync” complains that “The Old Trust Store does not exist”, you first need to tell Mono how to find these certificates, this page describes how to do it:
关于c# - 如何使用单声道解决 OSX 上的 SecureChannelFailure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41827960/