Гость
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Ошибка "The remote certificate is invalid according to the validation procedure" / 3 сообщений из 3, страница 1 из 1
22.03.2016, 11:30
    #39197803
Bator
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Ошибка "The remote certificate is invalid according to the validation procedure"
Есть WCF веб-сервис, хостится на IIS.
Один из методов обращается через прокси к внешнему сайту на https.
Несколько дней назад на том сайте обновился сертификат и с тех пор в методе в месте, где идет обращение к внешнему сайту, выдается ошибка "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel", в трассировке еще написано про "The remote certificate is invalid according to the validation procedure".
Все это происходит на боевом веб-сервисе, если ставить веб-сервис на других компьютерах, то ошибки нет.
При обращении к другим сайтам (), к примеру https://ya.ru - ошибки нет

Может кто-то сталкивался с подобным:

• На целевом сайте обновился сертификат
• Запрос идет через прокси
• На многих компьютерах все работает нормально, а на одном (боевом) стала выдаваться ошибка «The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.»
• На боевом сервере браузером (через ту же прокси) целевой сайт открывается без ошибок
• Запрос на https://ya.ru ошибок не выдает






Написал тестовый метод:
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
 public string GetUrlText(string targetUrl)
        {
            string res = null;

            HttpWebRequest reqGet = (HttpWebRequest)WebRequest.Create(targetUrl);

            // если в настройках есть прокси, то указываем настройки прокси
            if (String.IsNullOrEmpty(WebConfigurationManager.AppSettings["Proxy.Host"]) == false)
            {
                reqGet.Proxy = new WebProxy(WebConfigurationManager.AppSettings["Proxy.Host"], false, null,
                    new NetworkCredential(
                        WebConfigurationManager.AppSettings["Proxy.User"],
                        WebConfigurationManager.AppSettings["Proxy.Pwd"],
                        WebConfigurationManager.AppSettings["Proxy.Domain"])
                    );
            }
 
            reqGet.Method = "GET";
            reqGet.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
            reqGet.Timeout = 700000;

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // ssl у них отключен

            using (WebResponse resp = reqGet.GetResponse())
            {
                var stream = resp.GetResponseStream();
                if (stream != null)
                {
                    var sr = new StreamReader(stream);
                    res = sr.ReadToEnd();
                }
            }

            return res;
        }



для яндекса возвращает текст html, а целевого сайта выдает такой ответ:
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <s:Fault>
         <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode>
         <faultstring xml:lang="ru-RU">The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</faultstring>
         <detail>
            <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
               <HelpLink i:nil="true"/>
               <InnerException>
                  <HelpLink i:nil="true"/>
                  <InnerException i:nil="true"/>
                  <Message>The remote certificate is invalid according to the validation procedure.</Message>
                  <StackTrace>at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
   at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.ConnectStream.WriteHeaders(Boolean async)</StackTrace>
                  <Type>System.Security.Authentication.AuthenticationException</Type>
               </InnerException>
               <Message>The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</Message>
               <StackTrace>at System.Net.HttpWebRequest.GetResponse()
   at PricingService.PrSrv.GetUrlText(String baseUrl)
   at SyncInvokeGetUrlText(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace>
               <Type>System.Net.WebException</Type>
            </ExceptionDetail>
         </detail>
      </s:Fault>
   </s:Body>
</s:Envelope>
...
Рейтинг: 0 / 0
22.03.2016, 13:35
    #39197936
Axeleron
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Ошибка "The remote certificate is invalid according to the validation procedure"
Bator, разные причины могут быть, потому гугл в помощь.
...
Рейтинг: 0 / 0
22.03.2016, 18:12
    #39198242
Bator
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Ошибка "The remote certificate is invalid according to the validation procedure"
AxeleronBator, разные причины могут быть, потому гугл в помощь.

Настоящие герои всегда идут в обход (-:

На самом деле все эти версии за несколько дней были проверены, но ни исправить, ни найти причину не удалось.

Уже после этого поста сделали две вещи: перезапустили сервер и сменили настройки на другую прокси и все исправилось.
Вернули настройку на старую прокси и проблема не вернулась.
Предполагаю, что помог перезапуск самого сервера.
...
Рейтинг: 0 / 0
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / Ошибка "The remote certificate is invalid according to the validation procedure" / 3 сообщений из 3, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]