Мы находимся в процессе перемещения нашего веб-API на основе Apache в другое место, и поэтому IP-адрес меняется.Новый компьютер с веб-API использует ту же версию Apache, имеет те же конфигурации vhost.conf и SSL и использует те же файлы сертификатов, что и старый веб-API.
Как только мы изменили DNS на точкуна новом компьютере с веб-API мы заметили сообщения об ошибках ниже в нашей службе WCF C # 4.5, работающей на Windows 2012 R2 Servier (теперь я буду называть ее машиной службы WCF).Я в состоянии поразить новую целевую страницу веб-API через chrome на своем локальном рабочем столе, через https, что позволяет мне полагать, что это особая проблема на машине службы WCF.Я также проверил работоспособность, чтобы убедиться, что могу подключиться к новому IP-адресу и порту с компьютера службы WCF.
.NET 4.5 выполняет ли кэширование каких-либо файлов сертификатов, и если IP-адрес изменяется, он выбрасывается?
Примечание.Служба WCF является клиентом в этом сценарии, а веб-API на основе Apache является сервером, и они взаимодействуют через HTTPS
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, 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.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
версия SSL непосредственно из нашего файла .conf
SSLProtocol all -SSLv2 -SSLv3 -TLSv1
код службы WCF для доступа к веб-API Apache
authServiceURI = authServiceBaseURI + "/v1/me";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authServiceURI);
request.UseDefaultCredentials = false;
request.Headers["Authorization"] = "Bearer " + bearerToken;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (response)
{
if (response.StatusCode == HttpStatusCode.OK)
{
StreamReader sr = new StreamReader(response.GetResponseStream());
JObject jObj = JObject.Parse(sr.ReadToEnd());
JProperty usernameProp = jObj.Property("user_name");
JProperty clientidProp = jObj.Property("client_id");
if(usernameProp != null)
{
string username = usernameProp.Value.ToString();
string clientID = clientidProp.Value.ToString();
UserService us = new UserService();
User u = us.GetByLogin(username);
if (u != null)
{
authenticatedToken = new AuthToken();
authenticatedToken.AuthenticatedUser = u;
authenticatedToken.AuthMethod = AuthType.OAuth2;
authenticatedToken.ClientID = clientID;
}
}
}
}