Bonjour,
Je dois implémenter un appel à une simple ressource REST afin de listé des utilisateurs.
Cette resource REST demande une authentification client et server. Voici mon appel de test:
Ce client de test fonctionne parfaitement depuis l'environnement Visual. Par contre dés que je met ce client de test sur mon site IIS j'ai l'exception suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public string TestAPI() { ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://xxxx-xxxx.com/utilisateurs"); request.Method = "GET"; X509Certificate2 cert = new X509Certificate2(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "App_Data") + "/client_certificate.p12", "password", X509KeyStorageFlags.MachineKeySet); request.ClientCertificates.Add(cert); Stream stream = request.GetResponse().GetResponseStream(); StreamReader reader = new StreamReader(stream); string sLine = reader.ReadLine(); return sLine; } public bool AcceptAllCertifications(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certification, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; }
[Win32Exception (0x80004005): Le message reçu était inattendu ou formaté de façon incorrecte]
[IOException: L'opération de déchiffrement a échoué, consultez l'exception interne.]
System.Net.Security._SslStream.ProcessReadErrorCode(SecurityStatus errorCode, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest, Byte[] extraBuffer) +2775740
System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) +7821574
System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) +175
System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) +132
System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) +120
System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) +586
System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) +2835990
System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +22
System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +412
[WebException: La connexion sous-jacente a été fermée : Une erreur inattendue s'est produite lors de la réception.]
System.Net.HttpWebRequest.GetResponse() +7769892
TestClass.TestAPI() in c:\Users\Administrateur\desktop\test\App_Code\Class1.cs:36
_Default.Button1_Click(Object sender, EventArgs e) in c:\Users\Administrateur\desktop\test\Default.aspx.cs:18
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
Merci d'avance.
Partager