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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:17:11+00:00 2026-06-17T11:17:11+00:00

I am trying to log in to a website using HtmlUnit (Java Library), and

  • 0

I am trying to log in to a website using HtmlUnit (Java Library), and am getting an exception that I feel I could just ignore. The exception is “javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated”. I’ve narrowed this down to the certificate supports “www.thesite.com”, however it does use “somedomain.thesite.com”. The error I believe is due to the certificate not naming the other subdomain it uses in some javascript functions. It’s very strange as when using Firefox by hand, I do not see these exceptions, making me think there is something else happening.

Below is the code I am using:

// <editor-fold desc="User Credentials and site.">
String user = "auser";
String password = "apassword";

String mainUrl = "https://www.awebsite.com/";

// Setup Ajax & Cookies
AjaxController ajaxController = new AjaxController();
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiesEnabled(true);

// Setup WebClient
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setAppletEnabled(true);
webClient.setCssEnabled(true);
webClient.setJavaScriptEnabled(true);
webClient.setAjaxController(ajaxController);
webClient.setThrowExceptionOnScriptError(false);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setCookieManager(cookieManager);

/*
 * Provider p = new sun.security.pkcs11.SunPKCS11();
 * Security.addProvider(p);
 */

//webClient.set
HtmlPage page = null;

try {
    webClient.setUseInsecureSSL(true);
    page = webClient.getPage(mainUrl);

    // fill in form
    HtmlForm htmlForm = page.getFormByName("thisForm");
    HtmlInput userField = htmlForm.getInputByName("Username");
    HtmlInput passwordField = htmlForm.getInputByName("Password");

    // Enter login and password
    userField.setValueAttribute(user);
    passwordField.setValueAttribute(password);

    //HtmlPage mainMenuPage = htmlForm.click();
    HtmlElement element = htmlForm.getInputByValue("Login");

    page = element.click();
    webClient.waitForBackgroundJavaScript(5000); // pause if

    System.err.println(page.asText());
    System.err.println(page.asXml());

} catch (Exception ex) {
    ex.printStackTrace();
}

webClient.closeAllWindows();

}

As you can see, I have enabled ‘webClient.setUseInsecureSSL(true);’ in the HtmlUnit library. I figure this should do it. However, at this point I am stuck.

Here is the exception error I am getting:

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:776)
    at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:152)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1439)
    at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1358)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:307)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373)
    at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:358)
    at com.mycompany.extract.Program.main(Program.java:62)

Any ideas, or suggestions? The program simply doesn’t continue after this error, I don’t care if the certificate is bad (it is a valid cert, just using a different subdomain) as well, the certificate is out of my control.

  • 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-17T11:17:12+00:00Added an answer on June 17, 2026 at 11:17 am

    The problem is that you need the valid cert for that submdomain. Get it, and add it to your jssecacerts in the version of Java you are using.

    I did this using InstallCert.java. There is some helpful documentation here: http://miteff.com/install-cert and possibly here: http://pinchii.com/home/tag/jssecacerts/

    A simple google search for “InstallCert.java” should give you plenty of results.

    Good Luck!

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

Sidebar

Related Questions

I'm trying to write a Java class to log in to a certain website.
I'm trying to Log into a website using WebRequests in C# But the website
I am trying to post a request to log in to a website using
im trying to import log in with facebook opportunity to my website, im using
I've been trying to incorporate a log of usage on my website. I'm using
I'm trying to make a program using java to access this website by inserting
I am trying to log in a website using php via cURL. But the
I'm using this webbrowswer feature of C#. Trying to log in a website through
I'm trying to generate a PDF using WKHTMLTOPDF that requires me to first log
I am trying to log in to a website using .NET 4.5 HttpClient and

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.