sso 单点登录
This commit is contained in:
@@ -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.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -55,6 +57,40 @@ namespace BLL.Common
|
||||
}
|
||||
return strPostReponse;
|
||||
}
|
||||
private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
|
||||
{
|
||||
return true; //总是接受
|
||||
}
|
||||
|
||||
public static string PostJsonByHttps(string url, string jsonParams)
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
HttpWebRequest request = null;
|
||||
CookieContainer cookie = new CookieContainer();
|
||||
//HTTPSQ请求
|
||||
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.CookieContainer = cookie;
|
||||
request.ProtocolVersion = HttpVersion.Version11;
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
request.KeepAlive = true;
|
||||
byte[] byteData = Encoding.UTF8.GetBytes(jsonParams);
|
||||
int length = byteData.Length;
|
||||
request.ContentLength = length;
|
||||
|
||||
using (Stream stream = request.GetRequestStream())
|
||||
{
|
||||
stream.Write(byteData, 0, byteData.Length);
|
||||
}
|
||||
|
||||
var response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
using (StreamReader st = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
|
||||
{
|
||||
return st.ReadToEnd().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private static HttpWebRequest CreateHttpRequest(string url, string requestType, string token, params object[] strJson)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user