首页 \ 问答 \ 尽管设置了ServerCertificateValidationCallback,但无法创建SSL / TLS安全通道(Could not create SSL/TLS secure channel, despite setting ServerCertificateValidationCallback)

尽管设置了ServerCertificateValidationCallback,但无法创建SSL / TLS安全通道(Could not create SSL/TLS secure channel, despite setting ServerCertificateValidationCallback)

我正在尝试建立SSL / TLS连接以使用自签名证书测试服务器 。 通过不安全的渠道进行沟通没有问题。

以下是我基于此解决方案编写的示例代码: 使用HttpClient C# 允许不可信的SSL证书 忽略证书错误? .NET客户端连接到ssl Web API

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

var c = new HttpClient();
var r = c.GetAsync("https://10.3.0.1:8443/rest/v1").Result;
if (r.IsSuccessStatusCode)
{
    Log.AddMessage(r.Content.Get<string>());
}
else
{
    Log.AddMessage(string.Format("{0} ({1})", (int)r.StatusCode, r.ReasonPhrase));
}

也试过这个:

var handler = new WebRequestHandler();
handler.ServerCertificateValidationCallback = delegate { return true; };
var c = new HttpClient(handler);
...

和这个

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

但每次我有一个例外:

InnerException: System.Net.Http.HttpRequestException
   _HResult=-2146233088
   _message=An error occurred while sending the request.
   HResult=-2146233088
   IsTransient=false
   Message=An error occurred while sending the request.
   InnerException: System.Net.WebException
        _HResult=-2146233079
        _message=The request was aborted: Could not create SSL/TLS secure channel.
        HResult=-2146233079
        IsTransient=false
        Message=The request was aborted: Could not create SSL/TLS secure channel.
        Source=System
        StackTrace:
             at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
             at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
        InnerException: 

我做错了什么? 为什么我无法连接到此服务器(它具有无效的自签名证书)


I'm trying to establish SSL/TLS connection to test server with self-signed certificate. Communication through unsecure channel worked without issues.

Here is my sample code, which I've written based on this solutions: Allowing Untrusted SSL Certificates with HttpClient C# Ignore certificate errors? .NET client connecting to ssl Web API

ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

var c = new HttpClient();
var r = c.GetAsync("https://10.3.0.1:8443/rest/v1").Result;
if (r.IsSuccessStatusCode)
{
    Log.AddMessage(r.Content.Get<string>());
}
else
{
    Log.AddMessage(string.Format("{0} ({1})", (int)r.StatusCode, r.ReasonPhrase));
}

also tried this:

var handler = new WebRequestHandler();
handler.ServerCertificateValidationCallback = delegate { return true; };
var c = new HttpClient(handler);
...

and this

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

but each time I've got an exception:

InnerException: System.Net.Http.HttpRequestException
   _HResult=-2146233088
   _message=An error occurred while sending the request.
   HResult=-2146233088
   IsTransient=false
   Message=An error occurred while sending the request.
   InnerException: System.Net.WebException
        _HResult=-2146233079
        _message=The request was aborted: Could not create SSL/TLS secure channel.
        HResult=-2146233079
        IsTransient=false
        Message=The request was aborted: Could not create SSL/TLS secure channel.
        Source=System
        StackTrace:
             at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
             at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
        InnerException: 

What do I do wrong? Why I can't connect to this server (which has invalid-self-signed certificate)


原文:https://stackoverflow.com/questions/32994464
更新时间:2024-01-27 10:01

最满意答案

只需选择你想回去的哈希,并在你的克隆做:

git reset --hard hash# 
git push -f origin branch

其中branch是您要推送的分支的名称。 瞧。 小心推动力量。 你可能想复制你的工作目录,直到你熟悉它为止。


Just pick the hash you want to go back to and in your clone do:

git reset --hard hash# 
git push -f origin branch

where branch is the name of the branch you want to push. Voilà. Be carefully with the force push. You may want to copy your working directory until you are familiar with it.

相关问答

更多
  • 只需选择你想回去的哈希,并在你的克隆做: git reset --hard hash# git push -f origin branch 其中branch是您要推送的分支的名称。 瞧。 小心推动力量。 你可能想复制你的工作目录,直到你熟悉它为止。 Just pick the hash you want to go back to and in your clone do: git reset --hard hash# git push -f origin branch where branch i ...
  • 要删除本地最后两个提交,我建议使用: git reset --hard HEAD^^ Rebase是一个完全不同的操作,不会帮助你。 To remove the last two commits locally I'd suggest using: git reset --hard HEAD^^ Rebase is a completely different operation that won't help you here.
  • 假设你想要一个看起来像的回购 /rootOfTheRepo .git /walmart /bestbuy 你能做的是: 通过将文件移动到最终仓库中的位置来准备子项目 进入其中一个repo并从另一个获取提交 合并两个master分支 在bash中,它看起来像是从你的本地克隆: cd /path/to/walmartRepo mkdir walmart git mv file1 file2 dir1 dir2 walmart git commit -am "Moved files" cd /pa ...
  • 删除.git文件夹可能会导致您的git存储库中的问题。 如果要删除所有的提交历史记录,但是将代码保持在当前状态,那么这样做是非常安全的: 查看 git checkout --orphan latest_branch 添加所有文件 git add -A 提交更改 git commit -am "commit message" 删除分支 git branch -D master 将当前分支重命名为主 git branch -m master 最后,强制更新您的存储库 git push -f origin mas ...
  • 我假设您在本地提交了最后两次提交。 然后你想做一个硬重置去2提交回来。 您可以在以后仍然需要的情况下创建两个提交的备份分支: # Make backup branch git branch backup # Do a hard reset of the current branch git reset --hard head~2 Thanks for your answers. I have found the answer in IDE iteslf. Right click the project ...
  • 我不认为github内置了这个,但有几种方法可以使用URL。 使用page?一些试验和错误page? 让你快速浏览历史的开始: https : //github.com/micropython/micropython/commits/master?page=242 由于您可以输入几乎精确的值,因此您可以输入几乎精确的值:您知道当前最新提交的哈希值和github表示约有8450次提交,因此可以将您带到第一页: https : //github.com/micropython/micropython/犯/主?后 ...
  • 我相信Github会根据电子邮件地址计算用户。 因此,如果您将这个wildcats.unh.edu地址添加到Github上的用户帐户,那么这些提交应归于您。 I believe that Github calculates users based on email address. So if you add that wildcats.unh.edu address to your user account on Github, those commits should be attributed to ...
  • 你应该能够做一个git merge ,因为坏的dev做了一个rebase,会抱怨,但鉴于她只是重新定位到初始提交,听起来解决冲突会相对容易。 如果您的本地存储库不知道提交 - 但是远程存储库知道 - 然后尝试创建远程存储库的新克隆,并查看您正在寻找的提交是否存在。 据我所知,如果提交远程存在,并且克隆存储库,您应该能够访问该提交。 I ended up downloading the zip of the repo from the last good commit on github, the ...
  • 您可以创建用户页面并粘贴屏幕截图或HTML页面等,但是,否则您需要在那里存储repo。 You could create user pages and paste a screenshot or an HTML page or something like but, but otherwise you need to store the repo there.
  • 您描述的步骤似乎是使用BFG工具的正确方法(基于他们的文档)。 请注意,BFG Repo Cleaner仅影响存储库的历史记录,并且不会触及提交历史记录中的最新提交。 换句话说,首先需要清理分支的尖端,然后运行BFG工具。 根据您当前的状态,首先使用或git rm web.config清除当前状态,提交更改,推送所有内容,然后运行BFG清理历史记录。 The steps you described seem like the correct way to use the BFG tool (as based ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)