Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:18:39+00:00 2026-05-23T09:18:39+00:00

I started following a tutorial that wasn’t cased around Android and got this: System.setProperty(javax.net.ssl.trustStore,

  • 0

I started following a tutorial that wasn’t cased around Android and got this:

    System.setProperty("javax.net.ssl.trustStore", "truststore");
    System.setProperty("javax.net.ssl.trustStorePassword", "password");

    SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault();
    try {
        Socket s = ssf.createSocket("192.168.2.11", 6543);
        PrintWriter out = new PrintWriter(s.getOutputStream());
        while (true){
            out.println("SSL TEST");
            Log.d("DATA", "DATA SENT");
        }



    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

I guess this boils down to a few questions:

  1. I do not have my own trust store created, but searching through tutorials and things online, I am not sure how to create one. Is there a way I can create or modify a trust store to have the certificates I need in it? (I am using a self-signed certificate if that makes any difference)

  2. How do I make things with the SSL handshake run smoothly? Right now, the error I am getting is:

    javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
    

    Honestly, I don’t really understand what that means.

  3. What settings or files do I need to modify on my Android device to make sure this connection can happen?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:18:40+00:00Added an answer on May 23, 2026 at 9:18 am

    1) It depends. Do you have a self signed cert on the server side and you are trying to validate your identity to the android device? Or are you on the android side trying to validate your idendity to the server? If it is the former , then please see this link: http://www.codeproject.com/KB/android/SSLVerification_Android.aspx?display=Mobile

    You want to pay particular attention to where it makes the KeyStore file.

    2) The reason you’re getting that error is because it doesn’t trust the server you are connecting either because you did not create the truststore correctly or you are connecting to a server whose certificate has not been added to the truststore. What exactly are you trying to connect to?

    3) Make sure you have the <uses-permission android:name="android.permission.INTERNET" /> in the manifest.xml.

    Edit
    My apologies, please see the changes I made to the first paragraph.

    Here is the part to initialize your keystore and truststore

    SSLcontext sslContext = SSLContext.getDefault();
    
    KeyStore trustSt = KeyStore.getInstance("BKS");
    TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    InputStream trustStoreStream = this.getResources().openRawResource(R.raw.truststore);
    trustSt.load(trustStoreStream, "<yourpassword>".toCharArray());
    trustManagerFactory.init(trustStre);
    
    KeyStore keyStore = KeyStore.getInstance("BKS");
    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    InputStream keyStoreStream = this.getResources().openRawResource(R.raw.keystore);
    keyStore.load(keyStoreStream, "<yourpassword>".toCharArray());
    keyManagerFactory.init(keyStore, "<yourpassword>".toCharArray());
    
    sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got started by following this awesome tutorial , but wanted to do the
I'm learning WPF and started with this MSDN tutorial. I was just following the
I am getting started with Symfony 2 & I am following this tutorial. Now,
I've just started learning CodeIgniter, and I'm following this authentication tutorial by nettuts+. I
I started to implement a repository pattern following this tutorial . Now In the
I'm following the tutorial at asp.net mvc3 at http://www.asp.net/mvc/tutorials/getting-started-with-mvc3-part3-cs @{ ViewBag.Title = Welcome; }
I've just started playing with Django and am loosely following the tutorial with my
Please consider the following code and the explanation from this Mozilla tutorial Using web
I'm following a tutorial http://fuelyourcoding.com/getting-started-with-jquery-mobile-rails-3/ transforming the views in a straightforward scaffolded Rails 3
Hello Entity Frameworks Gurus!! I've been following the official tutorial and have started a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.