ssl - Xamarin Android HttpClient Error when use from a Class -
i have following code errors out when going site has ssl. (error: securechannelfailure (the authentication or decryption has failed.) ssl cert valid. when httpclient code called directly there not issue. wrong code?
uri uri =new uri("https://jsonplaceholder.typicode.com/posts/1"); using (httpclient httpclient = new httpclientclass()) { var tt = await httpclient.getasync(uri); string tx = await tt.content.readasstringasync(); log.info(tag, tx); } public class httpclientclass : httpclient { private httpclient _httpclient = null; private httpclienthandler messagehandler = new xamarin.android.net.androidclienthandler(); public httpclientclass() { _httpclient = new httpclient(messagehandler); } }
code no problem
uri uri =new uri("https://jsonplaceholder.typicode.com/posts/1"); using (httpclient httpclient = new httpclient()) { var tt = await httpclient.getasync(uri); string tx = await tt.content.readasstringasync(); log.info(tag, tx); }
thanks https tls 1.2 in xamarin here solution. add nuget modernhttpclient paul betts , use below. should work within class or not.
uri uri = new uri("https://jsonplaceholder.typicode.com/posts/1"); using (var httpclient = new httpclient(new nativemessagehandler())) { var tt = await httpclient.getasync(uri); string tx = await tt.content.readasstringasync(); //log.info(tag, tx); }
Comments
Post a Comment