B4J Question [Solved] [ABMaterial] - using https (secure)

Discussion in 'B4J Questions' started by Harris, Apr 13, 2019.

  1. Harris

    Harris Well-Known Member Licensed User

    myApp.StartServerHTTP2(srvr, "srvr", port, 443,"keystore","b12xxxxx","b12xxxxx" ) ' port = 51046
    Is this correct?

    I purchased SSL cert from SSLs.com (namecheap)...

    I had my VPS provider setup the certs on my VPS.
    I created a keystore (named keystore) according to this command - and answering questions...

    keytool -keystore keystore -alias jetty -genkey -keyalg RSA

    Updated server with new jar and rebooted. The jar did start on the server, however
    now I can't run the app in my browser.
  2. Harris

    Harris Well-Known Member Licensed User

    2019-04-12 22:23:28.362:INFO::main: Logging initialized @6182ms to org.eclipse.jetty.util.log.StdErrLog
    abmapplication._startserverhttp2 (java line: 
    java.lang.IllegalStateException: No 
    Server ALPNProcessors!
        at org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory.<init>(ALPNServerConnectionFactory.java:
        at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:
        at com.ab.ccwatch.abmapplication._startserverhttp2(abmapplication.java:
        at com.ab.ccwatch.main._appstart(main.java:
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
        at java.lang.reflect.Method.invoke(Method.java:
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:
    That is what I get on my dev... which has no ssl certs...
    Copied jar to server, nothing shows up in the logs...
  3. alwaysbusy

    alwaysbusy Expert Licensed User

    You do have your keystore.jks file next to the jar? And ae running java 9+?
  4. Harris

    Harris Well-Known Member Licensed User

    No keystore.jks in File.DirApp...
    Just "keystore" file.


    java version "1.8.0_181"
    Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

    This process seems confusing - and of course it would - cause I ultimate dummie...

    Thanks AB
  5. alwaysbusy

    alwaysbusy Expert Licensed User

    that is fine

    I think it is your java version. 8 was a lot more complex than 9 is (in 9 ALPN is included, in 8 you have to do a lot of including yourself. Can't even remember all of it)
  6. Harris

    Harris Well-Known Member Licensed User

    So I need to update as you suggest...

    To what version? I have read many posts with updating to 11 (10, and others) and hearing many issues (real or not).

    My VPS is Ubuntu, 18.04 LTS.

    Not great with command line updates. Takes much google searching to find a suitable method to patch.
    Thanks God no matter how much I screw up, Linux always recovers, and I carry on - no harm - no foul.
    With MS, I would have to format Drive C:

  7. Harris

    Harris Well-Known Member Licensed User

    When I contacted my VPS provider who installed the cert, they had NO idea what I was referring to when I mentioned the "keystore" file to make my app work.... WTF?
  8. Harris

    Harris Well-Known Member Licensed User

    I will try java 9 update in the morning. it is 1 am here...
  9. DonManfred

    DonManfred Expert Licensed User

    I´m really not a pro in this but i want to share my 2cent:
    I do have a cheap VPS to play around with it.

    I am using letsencrypt certs to secure my webserver on the VPS.
    The plus on this certs is that they are Trusted ones.

    I did installed the certbot using ssh and their Documentations.


    For you i guess it is

    List of all Instructions

    Another Tutorial

    Hope it helps!?
    Last edited: Apr 13, 2019
    Johan Hormaza likes this.
  10. Harris

    Harris Well-Known Member Licensed User

    pre end myapp - output to ccwlogs.txt
    2019-04-13 11:26:21.633:WARN:oejh.HttpParser:qtp335359181-24: Illegal character 0x16 in state=START for buffer HeapByteBuffer@53a4cb8a[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x03\xD6 \xE2R&\xCbx...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
    2019-04-13 11:26:21.860:WARN:oejh.HttpParser:qtp335359181-23: Illegal character 0x16 in state=START for buffer HeapByteBuffer@53a4cb8a[p=1,l=208,c=8192,r=207]={\x16<<<\x03\x01\x00\xCb\x01\x00\x00\xC7\x03\x03\xEc\x04\xF8\x17=`\x98...\x12\x00\x00\x00\x1b\x00\x03\x02\x00\x02\xAa\xAa\x00\x01\x00>>>\x00\x14\x00\x12\x04\x03\x08\x04\x04\x01\x05\x03\x08\x05\x05\x01\x08...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
     initing abmapplication
    Waiting for value (105 ms)
    Waiting for value (100 ms)
    Waiting for value (101 ms)
    Home Page Connected
    Waiting for value (101 ms)
    java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (Map).
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
        at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
        at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:188)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:844)
    Caused by: java.lang.RuntimeException: Object should first be initialized (Map).
        at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
        at anywheresoftware.b4a.objects.collections.Map.ContainsKey(Map.java:122)
        at com.ab.abmaterial.ABMaterial.UpdateFromCache(Unknown Source)
        at com.ab.ccwatch.homepage._websocket_connected(homepage.java:323)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
        ... 7 more
    Updated server to open-jdk 11
    Same issue... arrggg.
    Last edited: Apr 13, 2019
  11. OliverA

    OliverA Expert Licensed User

    Looks like a different issue to me
  12. OliverA

    OliverA Expert Licensed User

    Are you using a port # to access your ABM application?
  13. Harris

    Harris Well-Known Member Licensed User

  14. Harris

    Harris Well-Known Member Licensed User

    I don't have a redirect filter - as per erels SSL tutorial - SHould I Have?
  15. OliverA

    OliverA Expert Licensed User

    Make sure the 443 is not 443, but the port you are using (51046)
  16. Harris

    Harris Well-Known Member Licensed User

    myApp.StartServerHTTP2(srvr, "srvr", port, 443,"ccw.keystore", "b12bxxxx","b12bxxxx" )
  17. Harris

    Harris Well-Known Member Licensed User

    I shall try that...
  18. Harris

    Harris Well-Known Member Licensed User

    myApp.StartServerHTTP2(srvr, "srvr", port, port,"ccw.keystore", "b12bxxxx","b12bxxxx" )

    port is 51046

    Added HttpsFilter -
    This site can’t provide a secure connection

    Without filter: No connection now...

    public Sub StartServerHTTP2(srvr As Server, srvrName As String, srvrPort As Int, SSLsvrPort As Int,  SSLKeyStoreFileName As String, SSLKeyStorePassword As String, SSLKeyManagerPassword As String)

    Log("trying to startup")
    File.DirApp & "/www/" & ABMShared.AppName, "index.html", ABMShared.NeedsAuthorization)

    Dim ssl As SslConfiguration
    File.DirApp, SSLKeyStoreFileName) 'path to keystore file
        ssl.KeyStorePassword = SSLKeyStorePassword
        ssl.KeyManagerPassword = SSLKeyManagerPassword
        srvr.SetSslConfiguration(ssl, SSLsvrPort)
    ' start the server
    Log("trying to startup... :  "&srvrName)

    ' uncomment this if you want to directly access the app in the url without having to add the app name
        ' e.g. or if you are using port 80
        'srvr.AddFilter( "/", "ABMRootFilter", False )
    ' NEW V3 Cache Control
    ' NEW 4.00  custom error pages (optional) Needs the ABMErrorHandler class
        srvr.SetCustomErrorPages(CreateMap("org.eclipse.jetty.server.error_page.global""/" & ABMShared.AppName & "/error")) ' OPTIONAL
        srvr.AddHandler("/" & ABMShared.AppName & "/error""ABMErrorHandler"False' OPTIONAL
    "/ws/" & ABMShared.AppName, "ABMApplication")
    For i =0 To Pages.Size - 1
    "/ws/" & ABMShared.AppName & "/" & Pages.Get(i) , Pages.Get(i))
    If PageNeedsUpload.Get(i) Then
    "/" & ABMShared.AppName & "/" & Pages.Get(i) & "/abmuploadhandler""ABMUploadHandler"False)
    End If
        srvr.Port = srvrPort
        srvr.Http2Enabled = 
    #If RELEASE       
    #End If
    Dim joServer As JavaObject = srvr
    "context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionCookieConfig"Null).RunMethod("setMaxAge"Array(31536000)) ' 1 year
    ' NEW FEATURE! Each App has its own Session Cookie
    Dim secs As Long = ABMShared.CacheScavengePeriodSeconds ' must be defined as a long, else you get a 'java.lang.RuntimeException: Method: setIntervalSec not matched.' error
        joServer.GetFieldJO("context").RunMethodJO("getSessionHandler"Null).RunMethodJO("getSessionIdManager"Null).RunMethodJO("getSessionHouseKeeper"Null).RunMethod("setIntervalSec"Array As Object(secs))
    Dim jo As JavaObject = srvr
    Dim connectors() As Object = jo.GetFieldJO("server").RunMethod("getConnectors"Null)
    Dim timeout As Long = ABMShared.SessionMaxInactiveIntervalSeconds*1000
    For Each c As JavaObject In connectors

        ABMShared.CachedPages = srvr.CreateThreadSafeMap
    Log(" start except: "&LastException.Message)
    End Try       
    End Sub
    '----------------------END MODIFICATION 4.00-------------------------------
  19. OliverA

    OliverA Expert Licensed User

    make first port # 51046, this is for http:// access. Make the second port 51047. That will be for https:// access
  20. Harris

    Harris Well-Known Member Licensed User

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice