集册 Java实例教程 创建SSL上下文

创建SSL上下文

欢马劈雪     最近更新时间:2020-01-02 10:19:05

468
创建SSL上下文


import java.net.URL;// 来 自 时 代 J a v a - nowjava.com

import java.security.GeneralSecurityException;

import java.security.SecureRandom;

import javax.net.ssl.HostnameVerifier;

import javax.net.ssl.HttpsURLConnection;

import javax.net.ssl.SSLContext;

import javax.net.ssl.SSLSession;

import javax.net.ssl.X509TrustManager;


public class Main{

    public static void main(String[] argv) throws Exception{

        System.out.println(createSSLContext());

    }

    public static SSLContext createSSLContext()

            throws GeneralSecurityException {

        SSLContext context = SSLContext.getInstance("TLS");
        /* 
         来自 
        *N o w  J a v a  .   c o m*/

        context.init(

                null,

                
展开阅读全文