sso 单点登录

This commit is contained in:
jackchenyang
2024-06-24 10:28:40 +08:00
parent 34ca1fe4d7
commit 0c5cd77c5b
20 changed files with 422 additions and 11045 deletions
+36
View File
@@ -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)
{