title: How to resolve Javax.Net.Ssl.SSLHandshakeException in xamarin forms
body: <p>
  I am working on application in Xamarin forms for Android and iOS. App is getting data from Rest Api and It was working fine till yesterday but today some SSL issues was fixed from the server admin. Now Rest Api is working fine from Chrome browser and we are getting data. Even it is working on Visual Studio for Mac and working fine on simulator. </p>
  
  <p>But on Android it is not working. I have checked the domain with <a href="https://www.digicert.com/help/" rel="nofollow noreferrer">https://www.digicert.com/help/</a> and it gives the OK result as "Congratulations! This certificate is correctly installed.".</p>
  
  <p>I am using the below code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var response = client.GetAsync(urlCategories).Result;
  string content = "";
  if (response.IsSuccessStatusCode)
  {
      var responseContent = response.Content; 
      content = responseContent.ReadAsStringAsync().Result;
  }
  </code></pre>
  
  <p>Below is the complete stack trace of the error:</p>
  
  <pre class="lang-cs prettyprint-override"><code>{Javax.Net.Ssl.SSLHandshakeException: 
  Chain validation failed ---&gt; Java.Security.Cert.CertificateException: 
  Chain validation failed ---&gt; Java.Security.Cert.CertPathValidatorException: 
  OCSP response does not include a response for a certificate supplied in the OCSP request ---&gt; Java.Security.Cert.CertPathValidatorException: 
  OCSP response does not include a response for a certificate supplied in the OCSP request
     --- End of inner exception stack trace ---
     --- End of inner exception stack trace ---
     --- End of inner exception stack trace ---
    at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in &lt;42dc777b518744fdae9988e94489a4a0&gt;:0 
    at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00014] in &lt;42dc777b518744fdae9988e94489a4a0&gt;:0 
    at Javax.Net.Ssl.HttpsURLConnectionInvoker.Connect () [0x0000a] in &lt;1219ce5aae934ab095dc0e05b2110050&gt;:0 
    at Xamarin.Android.Net.AndroidClientHandler+&lt;&gt;c__DisplayClass43_0.&lt;ConnectAsync&gt;b__0 () [0x0005a] in &lt;1219ce5aae934ab095dc0e05b2110050&gt;:0 
    at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in &lt;d4a23bbd2f544c30a48c44dd622ce09f&gt;:0 
    at System.Threading.Tasks.Task.Execute () [0x00000] in &lt;d4a23bbd2f544c30a48c44dd622ce09f&gt;:0 
  --- End of stack trace from previous location where exception was thrown ---
    at Xamarin.Android.Net.AndroidClientHandler+&lt;DoProcessRequest&gt;d__45.MoveNext () [0x0012e] in &lt;1219ce5aae934ab095dc0e05b2110050&gt;:0 
  --- End of stack trace from previous location where exception was thrown ---
    at Xamarin.Android.Net.AndroidClientHandler+&lt;SendAsync&gt;d__40.MoveNext () [0x00230] in &lt;1219ce5aae934ab095dc0e05b2110050&gt;:0 
  --- End of stack trace from previous location where exception was thrown ---
    at System.Net.Http.HttpClient+&lt;SendAsyncWorker&gt;d__49.MoveNext () [0x000ca] in &lt;25ebe1083eaf4329b5adfdd5bbb7aa57&gt;:0 
  --- End of stack trace from previous location where exception was thrown ---
    at System.Net.Http.HttpClient+&lt;GetStringAsync&gt;d__54.MoveNext () [0x0007d] in &lt;25ebe1083eaf4329b5adfdd5bbb7aa57&gt;:0 
  --- End of stack trace from previous location where exception was thrown ---
    at Guldasta.Gen+&lt;GetMenuItems&gt;d__86.MoveNext () [0x00045] in E:\05_Xamarin_Projects\GuldastaApp\Guldasta\Guldasta\Guldasta\General\Gen.cs:62 
    --- End of managed Javax.Net.Ssl.SSLHandshakeException stack trace ---
  javax.net.ssl.SSLHandshakeException: Chain validation failed
      at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
      at com.android.okhttp.internal.io.RealConnection.connectTls(RealConnection.java:1477)
      at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:1423)
      at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:1367)
      at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:219)
      at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:142)
      at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:104)
      at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:392)
      at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:325)
      at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:489)
      at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
      at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
      at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(Unknown Source:0)
  Caused by: java.security.cert.CertificateException: Chain validation failed
      at com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:788)
      at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:612)
      at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:633)
      at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:678)
      at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:499)
      at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:422)
      at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:343)
      at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:94)
      at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:88)
      at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:203)
      at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:607)
      at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
      at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:357)
      ... 12 more
  Caused by: java.security.cert.CertPathValidatorException: OCSP response does not include a response for a certificate supplied in the OCSP request
      at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:133)
      at sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:225)
      at sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:143)
      at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:79)
      at com.android.org.conscrypt.DelegatingCertPathValidator.engineValidate(DelegatingCertPathValidator.java:44)
      at java.security.cert.CertPathValidator.validate(CertPathValidator.java:301)
      at com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:784)
      ... 24 more
  Caused by: java.security.cert.CertPathValidatorException: OCSP response does not include a response for a certificate supplied in the OCSP request
      at sun.security.provider.certpath.OCSPResponse.verify(OCSPResponse.java:416)
      at sun.security.provider.certpath.RevocationChecker.checkOCSP(RevocationChecker.java:709)
      at sun.security.provider.certpath.RevocationChecker.check(RevocationChecker.java:363)
      at sun.security.provider.certpath.RevocationChecker.check(RevocationChecker.java:337)
      at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:125)
      ... 30 more
      Suppressed: java.security.cert.CertPathValidatorException: Could not determine revocation status
          at sun.security.provider.certpath.RevocationChecker.buildToNewKey(RevocationChecker.java:1092)
          at sun.security.provider.certpath.RevocationChecker.verifyWithSeparateSigningKey(RevocationChecker.java:910)
          at sun.security.provider.certpath.RevocationChecker.checkCRLs(RevocationChecker.java:577)
          at sun.security.provider.certpath.RevocationChecker.checkCRLs(RevocationChecker.java:465)
          at sun.security.provider.certpath.RevocationChecker.check(RevocationChecker.java:394)
          ... 32 more
  </code></pre>
  
  <p>Do anyone have the idea how can solve this issue?</p>