B4J Question jRDC2 and SSL is this code right?

Alexander Stolte

Expert
Licensed User
Longtime User
Hello,

i am currently in the process of providing my VPS with SSL and I wanted to ask if the code in jRDC2 + SSL is correct or if I need to change something.

This is the normal jRDC2 code + the function for SSL

B4X:
Sub Process_Globals
    Public srvr As Server
    Public rdcConnector1 As RDCConnector
    Public const VERSION As Float = 2.1
    Type DBCommand (Name As String, Parameters() As Object)
    Type DBResult (Tag As Object, Columns As Map, Rows As List)
End Sub

Sub AppStart (Args() As String)
    srvr.Initialize("")
        
    rdcConnector1.Initialize
    
    ConfigureSSL(rdcConnector1.serverPort)
    
    srvr.Port = rdcConnector1.serverPort
    srvr.AddHandler("/test", "TestHandler", False)
    srvr.AddHandler("/rdc", "RDCHandler", False)
    srvr.Start
    Log($"jRDC is running (version = $1.2{VERSION})"$)
    StartMessageLoop
End Sub

Private Sub ConfigureSSL (SslPort As Int)
    'example of SSL connector configuration
    Dim ssl As SslConfiguration
    ssl.Initialize
    ssl.SetKeyStorePath(File.DirApp, "test2.keystore") 'path to keystore file
    ssl.KeyStorePassword = "123456"
    ssl.KeyManagerPassword = "654321"
    srvr.SetSslConfiguration(ssl, SslPort)
    'add filter to redirect all traffic from http to https (optional)
    srvr.AddFilter("/*", "HttpsFilter", False)
End Sub

with "rdcConnector1.serverPort" i get the port from the current connect RDC.

Greetings
 
Top