This update adds support for SSL sockets (client sockets).
Example:
You can use a custom keystore if needed. The first section in this blog explains how to create the keystore: https://assylias.wordpress.com/2012...er-from-android-with-self-signed-certificate/
You should then pass an input stream to InitializeSSL:
You can also use InitializeSSLAcceptAll method to accept all certificates automatically. This method is less secure and should be mainly used for testing.
Installation instructions:
- Download the attached zip file and copy the files to the internal libraries folder.
Example:
B4X:
Sub Process_Globals
Private so As Socket
Private astream As AsyncStreams
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
so.InitializeSSL("so", Null, "")
so.Connect("bing.com", 443, 0)
End Sub
Sub so_Connected (Successful As Boolean)
Log(Successful)
If Successful Then
astream.Initialize(so.InputStream, so.OutputStream, "astream")
Dim s As String = _
$"GET / HTTP/1.1
Host: www.bing.com
"$
s = s.Replace(CRLF, Chr(13) & Chr(10))
astream.Write(s.GetBytes("utf8"))
Else
Log(LastException)
End If
End Sub
Sub astream_NewData (Buffer() As Byte)
Log(BytesToString(Buffer, 0, Buffer.Length, "utf8"))
End Sub
Sub astream_Error
End Sub
Sub astream_Terminated
so.Close
End Sub
You can use a custom keystore if needed. The first section in this blog explains how to create the keystore: https://assylias.wordpress.com/2012...er-from-android-with-self-signed-certificate/
You should then pass an input stream to InitializeSSL:
B4X:
Dim in As InputStream = File.OpenInput(File.DirAssets, "test.keystore")
so.InitializeSSL("so", in, "123456")
in.Close
You can also use InitializeSSLAcceptAll method to accept all certificates automatically. This method is less secure and should be mainly used for testing.
Installation instructions:
- Download the attached zip file and copy the files to the internal libraries folder.