Hello Kris, On Thu, Aug 23, 2012 at 12:24 AM, Kris Owens <[email protected]> wrote: > I'm recompiling my app using MT 5.2.13, and I now get an exception calling > HttpWebRequest.GetRequestStream(). I'm using the exact same call in the > published version of the app and it works fine, so I don't think it's a > change on the server side. > > It looks like there have been a few changes in the HTTP/Web stack in the > last few months since I last compiled - does this look related to any of > those changes..?
It's hard to say without knowing which was the last version of MonoTouch was used to build your application. However all major changes are documented in the release notes [1]. My guess would be the fix for bug #5546 [2]. [1] http://docs.xamarin.com/ios/releases/MonoTouch_5 [2] https://bugzilla.xamarin.com/show_bug.cgi?id=5546 > System.Net.WebException: Error getting response stream (Write: The > authentication or decryption has failed.): SendFailure > ---> System.IO.IOException: The authentication or decryption has failed. > ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received > from server. Error code: 0x5 The 0x5 is one of the error code [3] that iOS returns when it dislike the X.509 certificate that it received from a server [4]. Now the value 0x5 (kSecTrustResultRecoverableTrustFailure) is not a fatal error but a warning that things are not totally correct (see some possible conditions documented in [3]). In such case you should check the certificate yourself and/or ask the user for confirmation (there are callbacks for this [5], and you can cache this answer to avoid asking over-and-over again). [3] https://developer.apple.com/library/ios/#documentation/security/Reference/certifkeytrustservices/Reference/reference.html [4] https://github.com/mono/mono/blob/mono-2-10/mcs/class/System/System.Security.Cryptography.X509Certificates/OSX509Certificates.cs#L44 [5] http://www.mono-project.com/UsingTrustedRootsRespectfully Sebastien > at > Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates > (Mono.Security.X509.X509CertificateCollection certificates) [0x000a1] in > /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:218 > at > Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 > () [0x00054] in > /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:105 > at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () > [0x00037] in > /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/HandshakeMessage.cs:105 > at > Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage > (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00039] in > /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs:81 > at > Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback > (IAsyncResult asyncResult) [0x00127] in > /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:397 > --- End of inner exception stack trace --- > at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback > (IAsyncResult asyncResult) [0x0002a] in > /Developer/MonoTouch/Source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs:100 > --- End of inner exception stack trace --- > at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult > asyncResult) [0x00043] in > /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:738 > at System.Net.HttpWebRequest.GetRequestStream () [0x00057] in > /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:756 > > Here's my code: > > var data = String.Format("api_type=json&user={0}&passwd={1}", username, > password); > > var uri = new Uri("https://ssl.reddit.com/api/login/" + username); > var webRequest = (HttpWebRequest)WebRequest.Create(uri); > webRequest.CookieContainer = new CookieContainer(); > webRequest.Method = "POST"; > webRequest.ContentType = "application/x-www-form-urlencoded"; > webRequest.ContentLength = ASCIIEncoding.ASCII.GetByteCount(data); > using (var postStream = webRequest.GetRequestStream()) // Exception here > { > } > > Thanks > Kris > > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch > _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
