Not correct work in Connecting to LDAP pgp key servers in Android

45 views
Skip to first unread message

Sargis Simonyan

unread,
Jun 14, 2017, 11:15:51 AM6/14/17
to DidiSoft Forum
Hi Peter,

here is one critical error, which is very important to fix. 

I am using a code, written according to description in your examples of "Connecting to LDAP pgp key servers in Android" and getting result that key submission was ok. But on server side we get no trace of this activity. 

It is a case where I am using a simple constructor of "LDAPClient" object. In case with constructor with username/password I am getting error which is shown in attached screenshot (LDAPException, code 81, Connection not established ....).

Important is that creation and uploading key without username and password on appropriate desktop application is working without any error. All things with are ok.


Here is the whole code itself:

......................

    @Override
public void onCreate(Bundle savedInstanceState) 
    {
    super.onCreate(savedInstanceState);
 
    mContext = getApplicationContext();
 
  userName = getIntent().getStringExtra(AppConstants.user_name);
  userMail = getIntent().getStringExtra(AppConstants.user_mail);
 
  try {
keyStore = new KeyStore(new com.didisoft.pgp.storage.AndroidContextFileKeyStorage(
mContext, userName+".keystore"), "nnn"); // I hardcoded password
filename = keyStore.getKeystoreFileName();
System.err.println("filename = "+filename);
file = getApplicationContext().getFileStreamPath(userName+"_pubkey.asc");
System.err.println("file = "+file+" "+file.exists());
    fIn = mContext.openFileInput(userName+"_pubkey.asc");
  catch (PGPException | IOException e)
  {
// TODO Auto-generated catch block
e.printStackTrace();
}
 
  requestServerAsync();
}
 
 
    //
    private void requestServerAsync()
    {
        reqs = new RequestServer();
        reqs.execute();
    }
    
    
   
 
// Async request of server
    class RequestServer extends AsyncTask<String, Integer, String> {
   
        
        public RequestServer() {
            super();
        }

        @Override
        protected void onPreExecute() {

            super.onPreExecute();
            
//          int ldapPort = 636; 
            int ldapPort = 389;
       
            // connect to LDAP server that supports pgp schema
            ldap = new LDAPClient(serverName, ldapPort, loginName, loginPass);
        //ldap = new LDAPClient(serverName, ldapPort);   
       
        try
        {
        final int length = (int) file.length();
     
        keyBytes = new byte[length];
       
        final int count = fIn.read(keyBytes, 0, keyBytes.length);
       
        System.err.println("count = "+count);
       
       // String asciiKey = new String(keyBytes, "ASCII");
 
       // System.err.println("Key = "+asciiKey);
        }
            catch (IOException e) 
        {
error = "Error: " +e.getMessage();
}
        }
        

        @Override
        protected String doInBackground(String... aurl1)
        {
        //"pubkey.asc"
        try 
        {
            submitted = ldap.submitKey(keyBytes);
        catch (IOException e) 
        {
error = "Error: " +e.getMessage();
}
       
            return null;
        }

        @Override
        protected void onProgressUpdate(Integer... progress) {}

        @Override
        protected void onPostExecute(String unused) 
        {
        updateUI();
        }
        
        //
        private void updateUI()
        {
        TextView tv = new TextView(LDAPDemo.this);
        tv.append("Testing key upload ... \n");
       
        if (error.compareTo("") != 0)
        {
        tv.append(error);
        }
       

        // this function returns true
        tv.append("\npublic key submitted = "+submitted);
         
        System.err.println("public key submitted = "+submitted);
            
        setContentView(tv);
        }
    }
}

Screenshot here:


and with error:


Can we please fix this? Thank you in advance!

DidiSoft Support

unread,
Jun 15, 2017, 4:49:10 PM6/15/17
to didisof...@googlegroups.com, Sargis Simonyan
Hi Sargis,

Thank you for granting me access to the SEMS server. Key submission is working fine and uploaded keys end up in the expected CKM mode.

The keys that you've tried to upload earlier (izzan23 and test2300) were uploaded successfully (you can see them in the menu Keys/Managed Keys > search)
You can observe your key upload activity in menu Reporting > Logs > Log: Verified Directory

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com
--
You received this message because you are subscribed to the Google Groups "DidiSoft Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to didisoft_foru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sargis Simonyan

unread,
Jun 16, 2017, 5:22:35 AM6/16/17
to DidiSoft Forum
Hi Peter,

I discussed with Karim and hi saw the activity on server. Logs shown creating a directory and the uploading key also.

So, there is some code snippet available, which is working correct. Did you check it from physical Android device? 

I uploaded a code snippet. I think it is correct, at least in sense of similarity to your published example. But apparently there is something wrong or not fully implemented. But I didn't found more example useful for our case.s o I am not sure what is wrong there or what is lacked.

Since the code itself is a part of your library, could you kindly provided it "as is", from the app which you are used yourself and got right result? I mean if you have it as a separate demo project you can send it and I will work on it from my side to reveal the problem. 

Many thanks,
Sargis

DidiSoft Support

unread,
Jun 16, 2017, 5:29:34 AM6/16/17
to didisof...@googlegroups.com, Sargis Simonyan
Hi Sargis,

I will prepare a small Android app that just creates and then uploads a key and will send it to you in about few hours.

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com

Sargis Simonyan

unread,
Jun 16, 2017, 5:48:46 AM6/16/17
to DidiSoft Forum, sarg...@gmail.com, sup...@didisoft.com
Excellent, thanks!

Can you please add there also a ldap object constructor with username/password? Since at me the server request with such constructed object returns error 81 (as shown in previously uploaded screenshot)?

DidiSoft Support

unread,
Jun 16, 2017, 1:33:08 PM6/16/17
to Sargis Simonyan, DidiSoft Forum
Hi Sargis,

I couldn't find a way to configure the SEMS keyserver with LDAP username/password access.

If you have created such restricton, please send me to support (at) didisoft.com the user credentials.

Kind Regards
Peter Kalef
Technical Support
DidiSoft Inc | Toll free (USA and Canada): 866-253-7568 | International: +1-501-313-0397 | Fax: +1-501-313-0397 | Web: www.didisoft.com
Reply all
Reply to author
Forward
0 new messages