Запрос был прерван: не удалось создать безопасный канал SSL / TLS (платежный шлюз) - PullRequest
0 голосов
/ 29 января 2020

Я знаю, что в одном заголовке слишком много вопросов. Никто из них не помог мне решить эту проблему. Поэтому я решил добавить код, который я написал.

Stream dataStream = request.GetRequestStream() - проблема возникает при достижении этой строки.

public ActionResult WebRequest()
{

    string currentIp = "";
    var host = Dns.GetHostEntry(Dns.GetHostName());
    foreach (var ip in host.AddressList)
    {
        if (ip.AddressFamily == AddressFamily.InterNetwork)
        {
            currentIp = ip.ToString();
        }
    }
    ServicePointManager.Expect100Continue = true;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
           | SecurityProtocolType.Tls11
           | SecurityProtocolType.Tls12
           | SecurityProtocolType.Ssl3; 
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://ecommerce.ufc.ge:18443/ecomm2/MerchantHandler");
    request.Method = "POST";
    string postData = "command=v&amount=<300>&currency=<981>&client_ip_addr=<" + currentIp + ">&description=<desc>&msg_type=SMS";
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = byteArray.Length;
    string myPath = Server.MapPath("//tbcCert.pem");
    X509Certificate certificate = new X509Certificate(myPath, "----", X509KeyStorageFlags.Exportable);
    request.PreAuthenticate = true;
    request.ClientCertificates.Add(certificate);
    Stream dataStream = request.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length);
    dataStream.Close();
    WebResponse response = request.GetResponse();
    string StatusDescription = ((HttpWebResponse)response).StatusDescription;
    using (dataStream = response.GetResponseStream())
    {
        StreamReader reader = new StreamReader(dataStream);
        string responseFromServer = reader.ReadToEnd();
    }
    response.Close();
    return View();
}

вот ошибка:

Запрос был прерван: не удалось создать безопасный канал SSL / TLS (платежный шлюз)

Пожалуйста, помогите мне найти, где моя ошибка.

...