顯示具有 webservice 標籤的文章。 顯示所有文章
顯示具有 webservice 標籤的文章。 顯示所有文章

2022年2月28日 星期一

[除錯] 無法建立 SSL/TLS 的安全通道

問題:

無法建立 SSL/TLS 的安全通道

收到來自傳輸資料流的未預期 EOF 或 0 個位元組


參考:

SecurityProtocolType 列舉

CA5386:避免將 SecurityProtocolType 值寫入程式碼


HttpWebRequest GetResponse()出現"要求已經中止: 無法建立 SSL/TLS 的安全通道"錯誤

[C#] 無法建立 SSL/TLS 的安全通道。解決方法

[VB.NET]加入HTTPS的服務參考遇到的問題

【原創】C# API 未能創建 SSL/TLS 安全通道 問題解決

要求已經中止: 無法建立 SSL/TLS 的安全通道。

HttpWebRequest GetResponse()出現"要求已經中止: 無法建立 SSL/TLS 的安全通道"錯誤

【茶包射手日記】.NET 3.5 TLS 1.2 踩雷記

.NET Framework 3.5 and TLS 1.2


解決C#呼叫有ssl憑證問題的網站出現遠端憑證是無效的錯誤問題

呼叫有ssl憑證問題的網站出現遠端憑證是無效的錯誤問題

ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;

private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)

{

    //// trust any certificate!!!

    //System.Console.WriteLine("Warning, trust any certificate");

    //return true;

            

    if (error == SslPolicyErrors.None)

    {

        return true;

    }

    var request = sender as HttpWebRequest;

    if (request != null)

    {

        var result = (request.RequestUri.Host == "11x.x.x.x" || request.RequestUri.Host == "192.16x.x.x");

        return result;

    }

    return false; 

}

CA5359: Do not disable certificate validation

AuthenticationException: Authentication failed, see inner exception. Win32Exception: 接收到的訊息超出預期或格式不正確。WebException: 要求已經中止: 無法建立 SSL/TLS 的安全通道。

System.Net.WebException: 要求已經中止: 無法建立 SSL/TLS 的安全通道 錯誤的另一種可能性2018-10-19



公開WebService:

政府資料開放平臺資料集清單

ListPriceWebService_NaturalGas

ListPriceWebService


解決:Winform .net 3.5

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;


//動態調用webservices Url

string url = "https://vipmember.tmtd.cpc.com.tw/OpenData/ListPriceWebService.asmx";


//無參數調用

object result1 = WebServiceHelper.InvokeWebService(url, "getCPCAviationFuelListPrice", null);          dataGridView1.DataSource = ((DataSet)result1).Tables[0];


2013年4月15日 星期一

[除錯] Web Services (ASP.NET + IIS) 出現如msgbox的訊息框,需透過 WebForm 的 Response.Write 即可!

流程:
WinForm (client) --network-- (server) Web Service --- Class --- DB


錯誤訊息:(在 Class msgbox時所引發的錯誤。)
當應用程式不使用 UserInteractive 模式執行時,顯示強制回應對話方塊或表單不是有效的作業。指定 ServiceNotification 或 DefaultDesktopOnly 樣式以顯示來自服務應用程式的告知。


實作:(寫在class裡的一段程式)
Try

Catch e As Exception
          'MsgBox(e.ToString) <-- 錯誤訊息的原因
          HttpContext.Current.Response.Write(e.ToString)

Finally
          '
End Try


參考:
ASP.NET 使用 MsgBox 顯示提示訊息
在 ASP.NET 也能使用 MessageBox 彈出對話方塊的功能
讓 ASP.NET 也可以使用 MsgBox 方法
Class類別中的Response、Server、Request未宣告解決方法(使用HttpContext.Current屬性)
SQL Injection技巧大全 <-- 用來測試 Sql select 的強度!!