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

  • SEARCH
  • Home
  • 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 8533279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:55:37+00:00 2026-06-11T09:55:37+00:00

I am trying to use Self signed certificate with JBoss and trying to trust

  • 0

I am trying to use Self signed certificate with JBoss and trying to trust in code. But I am getting javax.net.ssl.SSLPeerUnverifiedException:. Here are the things I tried,

Created a keystore

Created a keystore

Created a Trust Store

enter image description here

Configured SSL in JBoss AS 7.1.1

<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
  <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
    <ssl password="password" certificate-key-file="C:\work\certs\ks" protocol="TLSv1" verify-client="false" certificate-file="C:\work\certs\ks"/>
  </connector>
  <virtual-server name="default-host" enable-welcome-root="true">
    <alias name="localhost"/>
    <alias name="example.com"/>
  </virtual-server>
</subsystem>

Started the JBoss. Now I am able to access the site in chrome, by clicking ‘Proceed Anyway’ button.
enter image description here

But when I tried access from code, I am getting exception.

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
    at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
    at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:573)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:425)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
    at com.test.utility.TestHttps.main(TestHttps.java:61)

Here is my code,

public class TestHttps {

  private static TrustManager[] getTrustManagers() throws IOException, GeneralSecurityException {

    String trustStorePassword = "password";

    String alg = TrustManagerFactory.getDefaultAlgorithm();
    TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg);

    FileInputStream fis = new FileInputStream("C:\\work\\certs\\trust");
    KeyStore ks = KeyStore.getInstance("JKS");
    ks.load(fis, trustStorePassword.toCharArray());
    fis.close();

    tmFact.init(ks);

    TrustManager[] tms = tmFact.getTrustManagers();
    return tms;
  }

  public static void main(String[] args) throws Exception {

    SSLContext context = SSLContext.getInstance("TLS");
    context.init(null, getTrustManagers(), null);

    SSLSocketFactory ssf = new SSLSocketFactory(context);

    HttpClient base = new DefaultHttpClient();
    ClientConnectionManager ccm = base.getConnectionManager();
    SchemeRegistry registry = ccm.getSchemeRegistry();
    registry.register(new Scheme("https", 8443, ssf));

    try {

      DefaultHttpClient httpClient = new DefaultHttpClient(ccm, base.getParams());
      HttpGet getRequest = new HttpGet("https://localhost:8443/cafe/");

      HttpResponse response = httpClient.execute(getRequest);

      if (response.getStatusLine().getStatusCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
            + response.getStatusLine().getStatusCode());
      }

      BufferedReader br = new BufferedReader(new InputStreamReader(
          (response.getEntity().getContent())));
      String output;
      while ((output = br.readLine()) != null) {
        System.out.println(output);
      }
      httpClient.getConnectionManager().shutdown();
    } catch (ClientProtocolException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}

Please let me know what I am doing wrong. 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-06-11T09:55:38+00:00Added an answer on June 11, 2026 at 9:55 am

    I found the problem by setting the system property

    System.setProperty("javax.net.debug", "SSL,handshake,trustmanager");
    

    It seems the problem is with Jboss SSL configuration,

    <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
      <ssl password="password" certificate-key-file="C:\work\certs\ks" protocol="TLSv1" verify-client="false" certificate-file="C:\work\certs\ks"/>
    </connector>
    

    removed protocol=”TLSv1″. And imported the certificate to JRE keystore as

    1. accessed the site from browser
    2. exported the certificate
    3. imported to JRE keystore as

    keytool -import -alias localhost -file C:\ssl\test.cer -keystore %JAVA_HOME%\jre\lib\security\cacerts”

    After that the following code works like a charm.

    String path = "https://localhost:8443/cafe/";
    
    URL url = new URL(path);
    URLConnection conn = url.openConnection();
    
    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String output;
    while ((output = br.readLine()) != null) {
      System.out.println(output);
    }
    br.close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use a self-signed certificate in a ssl socket on windows8
I'm trying to create a website which uses SSL with a self-signed certificate. Here's
I'm trying to create a self-signed wildcard SSL certificate for use on a number
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I trying to do WCF using self-signed certificate. I found some solutions,but they need
I am trying to create a self-signed SSL certificate using OpenSSL (the version that
I'm trying to create a self signed certificate for use with Apache Tomcat 6.
I am trying to use the ASP.NET Web API Self-Host option with Windows authentication
I am trying to use __getitem__(self, x, y): on my Matrix class, but it
I am trying to setup a WCF Service with a self signed SSL. I

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.