1

In android studio code we are using key and trust, as per the document we created bks(emmtruststore.bks) file and pasted in raw folder

We are getting following error during device registration

error logs for android studio

03-30 11:36:11.930 2200-2817/org.wso2.emm.agent I/System.out: URL: https://192.168.4.216:9443/dynamic-client-web/register

03-30 11:36:12.135 2200-2817/org.wso2.emm.agent E/ServerUtilities: Error occurred while sending 'Post' request due to failure of server connection
03-30 11:36:12.135 2200-2817/org.wso2.emm.agent E/DynamicClientManager: Failed to contact server
    org.wso2.emm.agent.proxy.IDPTokenManagerException: Error occurred while sending 'Post' request due to failure of server connection
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.sendPostRequest(ServerUtilities.java:325)
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.postData(ServerUtilities.java:151)
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:144)
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:132)
        at android.os.AsyncTask$2.call(AsyncTask.java:288)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
        at java.lang.Thread.run(Thread.java:841)
     Caused by: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
        at com.android.org.conscrypt.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146)
        at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
        at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
        at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.sendPostRequest(ServerUtilities.java:307)
        at org.wso2.emm.agent.proxy.utils.ServerUtilities.postData(ServerUtilities.java:151) 
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:144) 
        at org.wso2.emm.agent.services.DynamicClientManager$SendRequest.doInBackground(DynamicClientManager.java:132) 
        at android.os.AsyncTask$2.call(AsyncTask.java:288) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
        at java.lang.Thread.run(Thread.java:841) 
03-30 11:36:12.135 2200-2200/org.wso2.emm.agent E/AuthenticationActivity: error occurred while retrieving client credentials
Community
  • 1
  • 1
Nikhil PV
  • 1,014
  • 2
  • 16
  • 29

1 Answers1

0

Since you are accessing the API through HTTPS, your client must have it's own truststore. You can use EMM's keystore as your truststore for this purpose. Or else, you can create your own truststore.

System.setProperty("javax.net.ssl.trustStore", "$EMM_HOME/repository/resources/security/wso2carbon.jks");  
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");  
System.setProperty("javax.net.ssl.trustStoreType", "JKS");
Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
  • Now i am getting this error 03-31 12:24:30.704 31994-32492/org.wso2.emm.agent I/System.out: URL: https://192.168.4.216:9443/dynamic-client-web/register 03-31 12:24:30.774 31994-32492/org.wso2.emm.agent E/org.wso2.emm.agent.proxy.clients.OAuthSSLClient: Error occurred while loading trust store. 03-31 12:24:30.779 31994-32492/org.wso2.emm.agent E/DynamicClientManager: Failed to contact server org.wso2.emm.agent.proxy.IDPTokenManagerException: Error occurred while loading trust store. – Nikhil PV Mar 31 '16 at 06:57
  • In MutualSSLClient class 'AuthenticatorFactory authenticatorFactory = new AuthenticatorFactory(); MutualSSLAuthenticator mutualSSLAuthenticator = (MutualSSLAuthenticator) authenticatorFactory.getClient(Constants.Authenticator.MUTUAL_SSL_AUTHENTICATOR, null,Constants.ADD_HEADER_CALLBACK); slSocketFactory = new SSLSocketFactory(mutualSSLAuthenticator.getCredentialCertificate(), Constants.KEYSTORE_PASSWORD, localTrustStore);' – Nikhil PV Mar 31 '16 at 07:18
  • In OAuthSSLClient class KeyStore localTrustStore = KeyStore.getInstance("JKS"); inStream =IdentityProxy.getInstance().getContext().getResources(). openRawResource(R.raw.wso2carbon); localTrustStore.load(inStream, Constants.TRUSTSTORE_PASSWORD.toCharArray()); – Nikhil PV Mar 31 '16 at 07:23
  • You can follow [Generating the OAuth 2.0 Access Token](https://docs.wso2.com/display/EMM201/Generating+the+OAuth+2.0+Access+Token) and see. – Abimaran Kugathasan Mar 31 '16 at 08:10