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