惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - neverlost

客户端开发杂记 html5 元素 来自 nativeformelements.com 闲扯,面向对象的ext4中的一些事儿1 Ext 4 beta1 发布似乎仍不给力 .net 下比较蛋疼的word 表格转excel表格 浅述教学上基于Media Player的视频切片方式 webservice传输数据量较大的情况的解决方案 - neverlost - 博客园 现场保障系统开发过程中增加并行处理(一) vs2010中文版+codesmith 5.2 安装失败 .net下开发windows服务的经验 .net 写的 webservice 给java调用 ext中使用tab方式 ext做列表页面关于查询多行的办法 关于架构的问题 ext的grid 获取页面内容方式 - neverlost - 博客园 微软.net下 charting 要注意的事情 - neverlost .net 获取 其他类型的webservice的方式以及看法 2条路 代码生成 or 配置 2.1 2条路 代码生成 or 配置 2
转的 winform开发连接webservice中单向证书
neverlost · 2010-05-20 · via 博客园 - neverlost

http://hi.baidu.com/srxljl/blog/item/8849a6ef4304961efdfa3cd3.html

ServicePointManager.ServerCertificateValidationCallback 属性

ms-help://MS.MSDNQTR.v90.chs/fxref_system/html/dcd4157d-dba4-4b60-164a-9e433a045d3c.htm

RemoteCertificateValidationCallback 委托

ms-help://MS.MSDNQTR.v90.chs/fxref_system/html/b3a0c706-1033-a543-01ca-23d09fcc121a.htm

WebRequest and SSL (The underlying connection was closed. Could not establish trust relationship with remote server.)
http://weblogs.asp.net/wim/archive/2004/04/02/106281.aspx

WinForm 调 SSL VPN WebService
http://www.cnblogs.com/zhongzf/archive/2006/10/27/386902.html

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;using System.IO;
using System.Net;
using System.Collections;
using System.Threading;using System.Net.Security;
using System.Security.Cryptography.X509Certificates;namespace GetCWData {
  
public partial class Form1 : Form {

     CookieContainer cc;

public Form1() {
       InitializeComponent();

       BeginGetData();
     }

private void BeginGetData() {
      
this.cc = new CookieContainer();this.txtUsername.Text = GetCWData.Properties.Settings.Default.Username;
      
this.txtPassword.Text = GetCWData.Properties.Settings.Default.Password;
      
string url = GetCWData.Properties.Settings.Default.BaseURL + GetCWData.Properties.Settings.Default.LoginPage;//ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
       ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate);

       HttpWebRequest request

= (HttpWebRequest)WebRequest.Create(url);
       request.Method
= "POST";
       request.ContentType
= "application/x-www-form-urlencoded";
       request.ContentLength
= 0;
       request.UserAgent
= "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.1124)";
       request.CookieContainer
= this.cc;

       HttpWebResponse response

= (HttpWebResponse)request.GetResponse();

       Stream stream

= response.GetResponseStream();
       StreamReader reader
= new StreamReader(stream, Encoding.UTF8);
      
string result = reader.ReadToEnd();this.txtHTML.Text = result;
     }
//internal class AcceptAllCertificatePolicy : ICertificatePolicy {
    
//   public AcceptAllCertificatePolicy() {
    
//   }//   public bool CheckValidationResult(ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb) {
    
//    // Always accept
    
//     return true;
    
//   }
    
//}

    
public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
      
//if (sslPolicyErrors == SslPolicyErrors.None) {
      
//   return true;
      
//}//Console.WriteLine("Certificate error: {0}", sslPolicyErrors);

      
//// Do not allow this client to communicate with unauthenticated servers.
      //return false;

      
return true;
     }

   }
}

如果是 webservice调用:

 HttpsService.LoginService httpsls = new Addin.HostDemo.HttpsService.LoginService();

                httpsls.ClientCertificates.Add(
                   X509Certificate.CreateFromCertFile(AppDomain.CurrentDomain.BaseDirectory + "CaresCA_ServerGrp_CA.cer"));
                ServicePointManager.ServerCertificateValidationCallback =
                        new RemoteCertificateValidationCallback(
                             (a, b, c, d) => { return true; }
                        );

                
                httpsls.login("test1", "123456");