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 5955475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:07:09+00:00 2026-05-22T18:07:09+00:00

I am currently working on my first android app and first api for my

  • 0

I am currently working on my first android app and first api for my organizations website. I am attempting to connect to the api from the android app using a secure connection. Our website has a test port on 8090 that I am attempting to use to test out the api but the problem I am running into is that I have a self-signed certificate on the website which from what I have read online, android apps don’t like. To make sure there isn’t a problem with the api, I have used it with an http rather than https connection and it works great. I have tried a couple solutions I found online including a couple from this site but none seem to work. Again, I don’t have much experience with developing for Android so much of my attempts were just copy and pasting from the solution I found online. Here are some links to what I have tried:

Https Connection Android

http://yekmer.posterous.com/how-to-accept-self-signed-certificates-in-and

there are other pages that I can’t find the links to now but below is the code that I am currently using to connect:

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://website.edu:8090/api.php?");

        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("method", "login"));
            nameValuePairs.add(new BasicNameValuePair("user", username.getText().toString()));
            nameValuePairs.add(new BasicNameValuePair("pass", md5(password.getText().toString())));
            nameValuePairs.add(new BasicNameValuePair("submitLogin", "1"));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
            HttpParams params = httppost.getParams();
            HttpConnectionParams.setConnectionTimeout(params, 45000);
            HttpConnectionParams.setSoTimeout(params, 45000);

            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
        } catch (ClientProtocolException e) {
            e.printStackTrace();                
        } catch (IOException e) {               
            e.printStackTrace();
        }

I would also like to add that buying a certificate is not an option since we don’t have a budget to work with so anything that would work around the self-signed certificate issue would be great. Thanks in advance!

  • 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-22T18:07:10+00:00Added an answer on May 22, 2026 at 6:07 pm

    Maybe ignore serificates at all for the time, until it is signed?

    Try this one:

    public static javax.net.ssl.TrustManager getTrustManager()
    {
        javax.net.ssl.TrustManager tm = new javax.net.ssl.X509TrustManager() {
    
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return null;
            }
    
            @Override
            public void checkClientTrusted(
                    java.security.cert.X509Certificate[] chain, String authType)
                    throws java.security.cert.CertificateException {
    
            }
    
            @Override
            public void checkServerTrusted(
                    java.security.cert.X509Certificate[] chain, String authType)
                    throws java.security.cert.CertificateException {        
            }
            };
            return tm;
    }
    
    
    
    public static DefaultHttpClient getThreadSafeClient() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException {
        DefaultHttpClient client = new DefaultHttpClient();
        ClientConnectionManager mgr = client.getConnectionManager();
        HttpParams cleintParams = client.getParams();
    
        cleintParams.setBooleanParameter("http.protocol.expect-continue", true);
        cleintParams.setBooleanParameter("http.protocol.warn-extra-input", true);
        // params.setIntParameter("http.socket.receivebuffer", 999999);
    
        //---->> SSL
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
    
        SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
       // HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
    
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));
    
        //<<------
    
    
    client = new DefaultHttpClient(new ThreadSafeClientConnManager(params, registry), cleintParams);
    
        return client;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on my first android app. In a listview, I need
I am currently working on my first website. I have no idea where to
The company I'm currently working for is using Selenium for Uniting-Testing our User Interface.
I am working on an Android app that utilizes the Google Maps API MapView,
I am currently working on my first asp.net mvc application. I am trying to
I have just started working on my first Android application and am going ok.
I’m currently working on a Android project and is very newbie to the Android
I am working on a fairly basic screen layout for my first Android application
i'm a beginner programmer and i'm currently working on a basic navigation app. I
I currently working on an issue tracker for my company to help them keep

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.