Java Generate Certificate Tool class Installcert.java resolve httpclient Access HTTPS error: PKIX path building failed

Source: Internet
Author: User
Tags sha1

Compilation: Javac Installcert.java
Run: Java installcert URL to access

The last side outputs:

Enter certificate to add to trusted keystore or ‘q‘ to quit: [1]

Enter 1 and then enter directly to generate a certificate named ' Jssecacerts ' in the appropriate directory. Copy the certificate to the $java_home/jre/lib/security directory

Installcert.java
/* Copyright 2006 Sun Microsystems, Inc. All rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, is permitted provided that the FOL lowing conditions * is met: * *-redistributions of source code must retain the above copyright * notice, this LIS T of conditions and the following disclaimer. * *-redistributions in binary form must reproduce the above copyright * Notice, this list of conditions and the FO Llowing Disclaimer in the * documentation and/or other materials provided with the distribution. * *-Neither the name of Sun Microsystems nor the names of its * contributors is used to endorse or promote pro Ducts derived * from this software without specific prior written permission. * * This software are provided by the COPYRIGHT holders and CONTRIBUTORS ' as * is ' and any EXPRESS OR implied warranties, I Ncluding, LIMITED to, * The implied warranties of merchantability and FITNESS for A partIcular * PURPOSE is disclaimed. In NO EVENT shall the COPYRIGHT OWNER OR * CONTRIBUTORS is liable for any DIRECT, INDIRECT, incidental, special, * EXEMPLA RY, or consequential damages (including, but not LIMITED to, * procurement of substitute GOODS OR SERVICES; LOSS of Use, DATA, OR * profits; or business interruption) however caused and on any theory of * liability, WHETHER in contract, STRICT liability, OR TORT (including * negligence OR OTHERWISE) Arising in an any-out-of-the-software, even IF advised of the possibility of SUCH DAMAGE. */import java.io.*;import java.net.url;import java.security.*;import java.security.cert.*;import javax.net.ssl.*;    public class Installcert {public static void main (string[] args) throws Exception {String host;    int port;    Char[] Passphrase; if ((args.length = = 1) | | (Args.length = = 2))        {string[] c = Args[0].split (":");        host = C[0]; Port = (C.length = = 1)?        443:integer.parseint (c[1]); String p = (Args.length = = 1)?        "Changeit": args[1];    Passphrase = P.tochararray ();        } else {System.out.println ("Usage:java installcert 

Java Generate Certificate Tool class Installcert.java resolve httpclient Access HTTPS error: PKIX path building failed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.