Java Add SSL certificate manually

Source: Internet
Author: User
Tags sha1 ssl certificate

An error occurred for sslhandshakeexception-unable to find valid certification path to requested target

Locate the corresponding Jssecacerts file or cacerts on the server, typically in the <jre home>/lib/security directory, execute the following code locally, add cert to the file,

Replace the old file with the newly generated jssecacerts (recommended to back up first)

Package com.rockbb.test;/* * 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, but not 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{args = new string[]{"Api.weixin.qq.com"} ; String Host;int port;char[] passphrase;if ((args.length = = 1) | | (Args.length = = 2)) {string[] c = Args[0].split (":"); host = c[0];p ort = (C.length = = 1)? 443:integer.parseint (c[1]); String p = (Args.length = = 1)? "Changeit": args[1];p assphrase = P.tochararray ();} Else{system.out.println ("Usage:java installcert 

Java Add SSL certificate manually

Related Article

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.