iOS Question Untrusted SSL Certificates

BillMeyer

Well-Known Member
Licensed User
Longtime User
Good Day,

In b4a I use the following to work around an untrusted SSL certificate (From @Warwound = WebviewExtras2)

B4X:
Sub Process_Globals

End Sub

Sub Globals
   Dim WebView1 As WebView
   Dim WebViewExtras1 As WebViewExtras
End Sub

Sub Activity_Create(FirstTime As Boolean)
   WebView1.Initialize("")
   Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
  
   WebViewExtras1.Initialize(WebView1)
   '   WebViewExtras1 now has all the methods and properties of WebView1 plus it's additonal methods and properties
   '   so you can use WebView1 to get/set WebView properties/methods
   '   or use WebViewExtras1 to get/set WebView1 properties/methods with the additional properties/method of WebViewExtras
  
   Dim WebViewClient1 As DefaultWebViewClient
   WebViewClient1.Initialize("WebViewClient1")
  
   WebViewExtras1.SetWebViewClient(WebViewClient1)
  
   WebViewExtras1.LoadUrl("http://google.co.uk/")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub WebViewClient1_ReceivedSslError(SslErrorHandler1 As SslErrorHandler, SslError1 As SslError)
   Log("WebViewClient1_ReceivedSslError: "&SslError1.GetUrl)
  
   '   you might want to take action depending on the type of the SSL error:
   Select SslError1.GetPrimaryError
     Case SslError1.SSL_DATE_INVALID
       Log("SSL_DATE_INVALID")
     Case SslError1.SSL_EXPIRED
       Log("SSL_EXPIRED")
     Case SslError1.SSL_IDMISMATCH
       Log("SSL_IDMISMATCH")
     Case SslError1.SSL_INVALID
       Log("SSL_INVALID")
     Case SslError1.SSL_MAX_ERROR
       Log("SSL_MAX_ERROR")
     Case SslError1.SSL_NOTYETVALID
       Log("SSL_NOTYETVALID")
     Case SslError1.SSL_UNTRUSTED
       Log("SSL_UNTRUSTED")
   End Select
  
   '   you might want to compare the url that raised the error with a known trusted URL and Proceed or Cancel with the page loading:
   If SslError1.GetUrl="http://my_trusted_domain.com" Then
     SslErrorHandler1.Proceed
   Else
     SslErrorHandler1.Cancel
   End If
  
End Sub

Particularly the "WebViewClient1_ReceivedSslError" sub works well.

My question is "Is there an equivalent in b4i ?"

I have used the Safari Controller as a workaround, but my clients are not happy with the "Unsafe Site" warning that pops up the first time before you can proceed.

I would appreciate some guidance or snippets here please.
 

BillMeyer

Well-Known Member
Licensed User
Longtime User
Thanks Erel - thats an unexplored avenue - I'll give it a shot.
 
Upvote 0
Top