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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:27:43+00:00 2026-05-15T12:27:43+00:00

I’m creating a web service (and test client) that uses mutual authentication. I’ve used

  • 0

I’m creating a web service (and test client) that uses mutual authentication. I’ve used this guide to create a CA and key/trust stores but instead of creating .p12 files for clients, I’ve used the “SETTING UP YOUR WEB SERVER” section to create a keystore for each client that I need to authenticate.

The server-side code is trivial and should return the name of the authenticated user:

import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;

@WebService()
public class ListProducts {

  @Resource WebServiceContext context;

  @WebMethod(operationName = "listProducts")
  public String listProducts() {
    return context.getUserPrincipal().toString();
  }
}

Whilst the client code looks like:

  System.getProperties().setProperty("javax.net.trustStore", "C:\\NetBeansProjects\\security-client\\client.jks");
  System.getProperties().setProperty("javax.net.trustStorePassword", "changeit");
  System.getProperties().setProperty("javax.net.keyStore", "C:\\NetBeansProjects\\security-client\\client.jks");
  System.getProperties().setProperty("javax.net.keyStorePassword", "changeit");

  ListProductsService lps = new ListProductsService();
  ListProducts lp = lps.getListProductsPort();

  System.out.println(lp.listProducts());

The security part of my web.xml file looks like this:

<security-constraint>
    <display-name>HTTPS</display-name>
    <web-resource-collection>
        <web-resource-name>All</web-resource-name>
        <description/>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <description>Force HTTPS</description>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<login-config>
    <auth-method>CLIENT-CERT</auth-method>
</login-config>

Just in case it helps, I’m deploying to GlassFish and I’ve used the Admin Console to set the SSL Network Listener to use SSL3, TLS and Client Authentication and filled in the relevant key store and trust store and set PKIX as the trust algorithm.

The problem is that the output from the client is ANONYMOUS. What I really want is the user info that’s printed in the certificate (e.g. CN=Joe Bloggs, OU=Some Org Unit, O=Some Org, L=AnyTown, ST=AnyState, C=US)

Looking through the MessageContext object that is also returned, the other fields seem to be populated correctly so I’m wondering why the security information isn’t being captured. I’m confident that there is SSL handshaking going on because when I use the -Djavax.net.debug=ssl,handshake the messages logged seem fine (plus, if I point the client to another keystore it falls over). Any ideas?

  • 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-15T12:27:43+00:00Added an answer on May 15, 2026 at 12:27 pm

    I took a different approach and got everything to work (finally). You can see the detail in this answer. The short story is that the authentication I’ve used in the question is too high level for Java to be able to access it at the Web Service level.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.