Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SeaskyWeChat
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
刘圳
SeaskyWeChat
Merge requests
!54
更新corpcore中的https请求
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
更新corpcore中的https请求
feature/liuzhen
into
develop
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
刘圳
requested to merge
feature/liuzhen
into
develop
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
fb927633
1 commit,
1 year ago
1 file
+
14
−
0
Expand all files
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
WeChat.CorpLib/Core/HTTPHelper.cs
+
14
−
0
Options
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
using
System.Net.Security
;
using
System.Security.Cryptography.X509Certificates
;
using
System.Web
;
namespace
WeChat.CorpLib.Core
@@ -20,6 +22,8 @@ namespace WeChat.CorpLib.Core
public
static
string
PostRequest
(
string
url
,
DataTypeEnum
ContentType
,
string
strData
)
{
string
result
=
string
.
Empty
;
ServicePointManager
.
ServerCertificateValidationCallback
=
new
System
.
Net
.
Security
.
RemoteCertificateValidationCallback
(
CheckValidationResult
);
ServicePointManager
.
SecurityProtocol
=
SecurityProtocolType
.
Ssl3
|
SecurityProtocolType
.
Tls
|
(
SecurityProtocolType
)
768
|
(
SecurityProtocolType
)
3072
;
WebRequest
webRequest
=
WebRequest
.
Create
(
url
);
webRequest
.
Method
=
MethodTypeEnum
.
Post
.
ToString
();
webRequest
.
ContentType
=
"application/"
+
ContentType
.
ToString
();
@@ -45,6 +49,8 @@ namespace WeChat.CorpLib.Core
public
static
string
GetRequest
(
string
url
)
{
string
result
=
string
.
Empty
;
ServicePointManager
.
ServerCertificateValidationCallback
=
new
System
.
Net
.
Security
.
RemoteCertificateValidationCallback
(
CheckValidationResult
);
ServicePointManager
.
SecurityProtocol
=
SecurityProtocolType
.
Ssl3
|
SecurityProtocolType
.
Tls
|
(
SecurityProtocolType
)
768
|
(
SecurityProtocolType
)
3072
;
WebRequest
webRequest
=
WebRequest
.
Create
(
url
);
webRequest
.
Method
=
MethodTypeEnum
.
Get
.
ToString
();
using
(
StreamReader
reader
=
new
StreamReader
(
webRequest
.
GetResponse
().
GetResponseStream
()))
@@ -53,8 +59,16 @@ namespace WeChat.CorpLib.Core
}
return
result
;
}
private
static
bool
CheckValidationResult
(
object
sender
,
X509Certificate
certificate
,
X509Chain
chain
,
SslPolicyErrors
errors
)
{
// 总是接受 认证平台 服务器的证书
return
true
;
}
}
/// <summary>
/// 带参数据类型
/// </summary>