Android Question Certificate X509

Antonio Ferreira

Member
Licensed User
I installed this certificate on an Android phone.
(I bypass the certificate verification by using hc.InitializeAcceptAll but don´t work).
How can I make http requests with this certificate?
I have b4a 9.0
Thanks
 

Antonio Ferreira

Member
Licensed User
Thank you Erel

this is my b4a.code

Dim XHTTP As String
XHTTP=Starter.Xservico.Trim & "/odata/cf_company?$select=cy_name,cy_var,cy_var2&$top=1&$orderby=cy_id"
XHTTP=XHTTP.Replace(" ","%20")
Dim job1 As HttpJob
job1.Initialize("Job1", Me)
job1.Download(XHTTP)
Wait for (job1) JobDone(job1 As HttpJob)
If job1.Success Then
Log("JOB1 Sucess")
Log(job1.GetString)
Dim json As JSONParser
Dim map1 As Map
json.Initialize(job1.GetString)
map1=json.NextObject
Dim M As Map
Dim List1 As List
List1.Initialize
List1=map1.Get("value")
tot=List1.Size
If tot>0 Then
M=List1.Get(0)
Log(M)
Starter.SQL1.ExecNonQuery2("UPDATE CF_INI SET version=?,cy_var=? ",Array As Object(M.Get("cy_var2"),M.Get("cy_var")))
Starter.Xversao=M.Get("cy_var2")
Starter.Xversao=Starter.Xversao.Trim
If Starter.Xversao.Trim.Length=0 Then
Starter.Xversao="2.5.6"
End If
Starter.Xcliente=M.Get("cy_var")
If Starter.Xcliente.Length>0 Then
Starter.Xcliente=Starter.Xcliente.Trim
End If
End If
End If


This is my logs



https://glosemobilecert.pconnect.biz/ws/odata/wo_trade?$select=tr_id&$top=1
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
JOB1 Sucess
<html>
<head>
<meta name="robots" content="noindex,nofollow">
<title>BIG-IP logout page</title>
<link rel="stylesheet" type="text/css" HREF="/public/include/css/apm.css">
<script src="/public/include/js/common.js" language="javascript"></script>
<script src="/public/include/js/u_plugin.js" language="javascript"></script>

<script language="javascript">
function InsertActivexControl(clsid, params)
{
var container = document.getElementById("logoutActivexContainer");

if (navigator.appName == "Microsoft Internet Explorer") {
var paramsCode = "";
for (var item in params) {
paramsCode += "<param name='" + item + "' value='" + params[item] + "'>";
}

container.innerHTML =
"<center><object classId=CLSID:" + clsid + " border=0 width=1 height=1>" +
paramsCode + "</object></center>";
}
else {
var pluginHost = new UPluginHost("", container);
var control = {"clsid": clsid, "width": 1, "height": 1};
pluginHost.hostControl(control, params);
}
}

function OnLoad()
{
var display_session = get_cookie("LastMRH_Session");
if(null != display_session) {
document.getElementById("sessionDIV").innerHTML = '<BR>The session reference number: &nbsp;' + display_session + '<BR><BR>';
document.getElementById("sessionDIV").style.visibility = "visible";
}
try
{
if (("undefined" != typeof(window.external))
&& ("unknown" != typeof(window.external))
&& ("undefined" != typeof(window.external.WebLogonNotifyUser))
&& ("unknown" != typeof(window.external.WebLogonNotifyUser)))
{
window.external.WebLogonNotifyUser();
}
}
catch(e) {};
try
{
if (get_cookie("F5_PWS") == "1")
{
document.cookie = "F5_PWS=0; path=/; expires=Fri, 01-Jan-1970 00:00:01 GMT";
var pwsClassId = "7E73BE8F-FD87-44EC-8E22-023D5FF960FF";
InsertActivexControl(pwsClassId, {"command": "exit"} );
}
}catch (e) {};
}
</script>
</head>
<body onload="OnLoad();">
<script>
try{
if(window.external && window.external.WebLogonOnAuthFailure) {
window.external.WebLogonOnAuthFailure();
}
}catch(e){};
try {
window.external.OnHostClose();
} catch(e) { }
</script>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" id="viewport" content="initial-scale=1.0" />
<meta name="robots" context="noindex,nofollow">
<script language="javascript">
//orientation toolbox
function setViewport(){
document.getElementById("viewport").setAttribute('content', Math.abs(window.orientation) == 90 ? 'width=device-height, initial-scale=1' : 'width=device-width, initial-scale=1.0' );
}
setViewport();
window.onorientationchange = function() {
setViewport();
}
</script>
<table id="page_header">
<tr >
<td id="header_leftcell"><img src='/public/images/customization/Common/GLOSEMOBILE_general_ui/logo_image_en.GIF'/></td>
<td id="header_rightcell"></td>
</tr>
<tr>
<td></td>
<td id="maxTimeoutTd"><span id="maxTimeoutTag" title=""></span></td>
</tr>
</table>
<noscript>
<div id="noscript_warning_red">JavaScript is not enabled. Please enable JavaScript in your browser or contact your system administrator for assistance.</div>
<div id="noscript_warning_newsession">To open a new session, please <A href="/">click here.</A></div>
</noscript>
<table id="main_table" class="logout_page">
<tr>
<td id="main_table_info_cell">
<table id="interaction_table">
<tr>
<td id="interaction_table_header">Your session could not be established.</td>
</tr>
<tr>
<td class="interaction_table_option_cell">
Message longer than Log limit (4000). Message was truncated.
act_geral2$ResumableSub_Btn_Gravar_Clickresume (java line: 1020)
java.lang.RuntimeException: JSON Object expected.
at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:50)
at b4a.example.act_geral2$ResumableSub_Btn_Gravar_Click.resume(act_geral2.java:1020)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:185)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1154)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (menu_config) Create, isFirst = true **
** Activity (menu_config) Resume **
** Activity (menu_config) Pause, UserClosed = true **
** Activity (menu_principal_b) Create, isFirst = true **
** Activity (menu_principal_b) Resume **
 

Antonio Ferreira

Member
Licensed User
Sorry Erel, i didn't know what "code tags" was

this is my b4a code, for an http request


B4X:
Dim XHTTP As String
    XHTTP=Starter.Xservico.Trim & "/odata/cf_company?$select=cy_name,cy_var,cy_var2&$top=1&$orderby=cy_id"
    XHTTP=XHTTP.Replace(" ","%20")
    Dim job1 As HttpJob
    job1.Initialize("Job1", Me)
    job1.Download(XHTTP)
    Wait for (job1) JobDone(job1 As HttpJob)
    If job1.Success Then
        Log("JOB1 Sucess")
        Log(job1.GetString)
        Dim json As JSONParser
        Dim map1 As Map
        json.Initialize(job1.GetString)
        map1=json.NextObject
        Dim M As Map
        Dim List1 As List
        List1.Initialize
        List1=map1.Get("value")
        tot=List1.Size
        If tot>0 Then
            M=List1.Get(0)
            Log(M)
            Starter.SQL1.ExecNonQuery2("UPDATE CF_INI SET version=?,cy_var=? ",Array As Object(M.Get("cy_var2"),M.Get("cy_var")))
            Starter.Xversao=M.Get("cy_var2")
            Starter.Xversao=Starter.Xversao.Trim
            If Starter.Xversao.Trim.Length=0 Then
                Starter.Xversao="2.5.6"
            End If
            Starter.Xcliente=M.Get("cy_var")
            If Starter.Xcliente.Length>0 Then
                Starter.Xcliente=Starter.Xcliente.Trim
            End If
        End If
    End If



This is the log with the error, only when i use the certificate X509




https://glosemobilecert.pconnect.biz/ws/odata/wo_trade?$select=tr_id&$top=1
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
JOB1 Sucess
<html>
  <head>
    <meta name="robots" content="noindex,nofollow">
    <title>BIG-IP logout page</title>
    <link rel="stylesheet" type="text/css" HREF="/public/include/css/apm.css">
    <script src="/public/include/js/common.js" language="javascript"></script>
    <script src="/public/include/js/u_plugin.js" language="javascript"></script>
    
    <script language="javascript">
      function InsertActivexControl(clsid, params)
      {
          var container = document.getElementById("logoutActivexContainer");
          
          if (navigator.appName == "Microsoft Internet Explorer") {
              var paramsCode = "";
              for (var item in params) {
                  paramsCode += "<param name='" + item + "' value='" + params[item] + "'>";
              }
              
              container.innerHTML =
                  "<center><object classId=CLSID:" + clsid + " border=0 width=1 height=1>" +
                  paramsCode + "</object></center>";
          }
          else {
              var pluginHost = new UPluginHost("", container);
              var control = {"clsid": clsid, "width": 1, "height": 1};
              pluginHost.hostControl(control, params);
          }
      }
      
      function OnLoad()
      {
        var display_session = get_cookie("LastMRH_Session");
        if(null != display_session) {
          document.getElementById("sessionDIV").innerHTML = '<BR>The session reference number: &nbsp;' + display_session + '<BR><BR>';
          document.getElementById("sessionDIV").style.visibility = "visible";
        }
        try
        {   
          if (("undefined" != typeof(window.external))
              && ("unknown" != typeof(window.external))
              && ("undefined" != typeof(window.external.WebLogonNotifyUser))
              && ("unknown" != typeof(window.external.WebLogonNotifyUser)))
          {
            window.external.WebLogonNotifyUser();
          }
        }
        catch(e) {};
        try
        {
            if (get_cookie("F5_PWS") == "1")
            {
                document.cookie = "F5_PWS=0; path=/; expires=Fri, 01-Jan-1970 00:00:01 GMT";
                var pwsClassId = "7E73BE8F-FD87-44EC-8E22-023D5FF960FF";
                InsertActivexControl(pwsClassId, {"command": "exit"} );
            }
        }catch (e) {};
      }
    </script>
  </head>
<body onload="OnLoad();">
<script>
try{
    if(window.external && window.external.WebLogonOnAuthFailure) {
        window.external.WebLogonOnAuthFailure();
    }
}catch(e){};
    try {
        window.external.OnHostClose();
    } catch(e) { }
</script>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" id="viewport" content="initial-scale=1.0" />
<meta name="robots" context="noindex,nofollow">
<script language="javascript">
//orientation toolbox
function setViewport(){
    document.getElementById("viewport").setAttribute('content', Math.abs(window.orientation) == 90 ? 'width=device-height, initial-scale=1' : 'width=device-width, initial-scale=1.0' );
}
setViewport();
window.onorientationchange = function() {
    setViewport();
}
</script>
<table id="page_header">
  <tr >
    <td id="header_leftcell"><img src='/public/images/customization/Common/GLOSEMOBILE_general_ui/logo_image_en.GIF'/></td>
    <td id="header_rightcell"></td>
  </tr>
  <tr>
     <td></td>
     <td id="maxTimeoutTd"><span id="maxTimeoutTag" title=""></span></td>
  </tr>
</table>
<noscript>
<div id="noscript_warning_red">JavaScript is not enabled. Please enable JavaScript in your browser or contact your system administrator for assistance.</div>
<div id="noscript_warning_newsession">To open a new session, please  <A href="/">click here.</A></div>
</noscript>
<table id="main_table" class="logout_page">
<tr>
        <td id="main_table_info_cell">
        <table id="interaction_table">
            <tr>
                <td id="interaction_table_header">Your session could not be established.</td>
            </tr>
            <tr>
                <td class="interaction_table_option_cell">
Message longer than Log limit (4000). Message was truncated.
act_geral2$ResumableSub_Btn_Gravar_Clickresume (java line: 1020)
java.lang.RuntimeException: JSON Object expected.
    at anywheresoftware.b4a.objects.collections.JSONParser.NextObject(JSONParser.java:50)
    at b4a.example.act_geral2$ResumableSub_Btn_Gravar_Click.resume(act_geral2.java:1020)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:185)
    at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1154)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7045)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (menu_config) Create, isFirst = true **
** Activity (menu_config) Resume **
** Activity (menu_config) Pause, UserClosed = true **
** Activity (menu_principal_b) Create, isFirst = true **
** Activity (menu_principal_b) Resume **
 
Top