При отправке POST из BPM на внешний веб-сервис возникает ошибка. Сайт крутится на https. Сервис тоже на https.
System.Net.WebException: Базовое соединение закрыто: Не удалось установить доверительные отношения для защищенного канала SSL/TLS. ---> System.Security.Authentication.AuthenticationException: Удаленный сертификат недействителен согласно результатам проверки подлинности.
в System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
в System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
в System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
в System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
в System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
в System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
в System.Net.ConnectStream.WriteHeaders(Boolean async)
--- Конец трассировки внутреннего стека исключений ---
в System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
в System.Net.HttpWebRequest.GetRequestStream()
в Terrasoft.Configuration.ContactLoad.ContactLoad.GetResponse()
в Terrasoft.Configuration.ContactLoad.ContactLoad.GetContacts()
в Terrasoft.Core.Process.UsrStartContactServiceMethodsWrapper.ScriptTask1Execute(ProcessExecutingContext context)
в Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)
Когда отправляю из Postman, респонс приходит корректно. Возможно дело в настройках IIS?
Вот код запроса :
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ServerCertificateValidationCallback = delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
httpWebRequest.Method = WebRequestMethods.Http.Post;
httpWebRequest.Timeout = 240000;
httpWebRequest.ContentType = "application/json";
httpWebRequest.ServicePoint.Expect100Continue = false;
httpWebRequest.ContentLength = data.Length;
Stream stream = httpWebRequest.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
try
{
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd().ToString();
}
}
catch (Exception ex)
{
throw new Exception("Failed to get response. : " + ex.Message);
return ex.Message;
}