java安全证书验证加密

这篇具有很好参考价值的文章主要介绍了java安全证书验证加密。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

SignatureProgram.java

import com.alibaba.fastjson.JSON;
import com.bestpay.mobilebiz.mapi.common.util.Base64Encrypt;
import com.bestpay.mobilebiz.mapi.common.util.CryptoUtil;
import com.bestpay.mobilebiz.mapi.common.util.KeyCertInfo;
import com.bestpay.mobilebiz.mapi.common.util.SignatureUtil;
import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.io.IOException;
import java.io.InputStream;
import java.security.*;
import java.security.cert.X509Certificate;
import java.util.*;

/**
 * @Description:
 * @Date: 2017/9/8
 */
public class SignatureProgram {

    public static void main(String[] args) throws GeneralSecurityException, IOException {

        //--------------生成签名demo------------
        InputStream resourceAsStream = Program.class.getClassLoader().getResourceAsStream("用户证书.p12");
        String passwd = "bestpay1";
        String alias = "conname";
        String keyStoreType = "PKCS12";

        KeyCertInfo keyCertInfo = CryptoUtil.fileStreamToKeyCertInfo(resourceAsStream,passwd,keyStoreType,alias);

        BouncyCastleProvider bouncyCastleProvider = new BouncyCastleProvider();
        Signature signature = Signature.getInstance("SHA256withRSA",bouncyCastleProvider);
        //请求参数
        Map<String,String> translateResultData=new HashMap<>();
        translateResultData.put("institutionCode","3178000003978343");
        translateResultData.put("merchantNo","8630029000159147");
        translateResultData.put("outTradeNo","201709191472852012807774852354");
        translateResultData.put("tradeAmt","11");
        translateResultData.put("subject","subject");
        translateResultData.put("productCode","68800020109");
        translateResultData.put("buyerLoginNo","18691832778");
        translateResultData.put("ccy","156");
        translateResultData.put("requestDate","2017-09-19 23:59:15");
        translateResultData.put("operator","operator");
        translateResultData.put("ledgerAccount","ledgerAccount");
        translateResultData.put("notifyUrl","notifyUrl");
        translateResultData.put("timeOut","0");
        translateResultData.put("storeCode","storeCode");
        translateResultData.put("storeName","storeName");
        translateResultData.put("goodsInfo","goodsInfo");
        translateResultData.put("remark","remark");
        String content = assembelSignaturingData(translateResultData);

        String sign = SignatureUtil.sign(signature,content, (PrivateKey) keyCertInfo.getPrivateKey());
        translateResultData.put("sign",sign);
        System.out.println(JSON.toJSONString(translateResultData));
        //--------------生成签名demo------------

        //--------------验证翼支付签名demo------------

        String jsonS="{\"errorCode\":\"DUIPLICAT_ORDER_ERROR\",\"errorMsg\":\"重复下单\",\"result\":null,\"sign\":\"n0EPUQ5fHpnnaxM7A84P7CKE4MXGvZuB7szIZx7VwCnjRfWs+6G+B0I+ay2IeJQufBn9ukfCPS0jgZsRWxy91g0SWWxCQFq7qhE3oTFG5xj7zC0Cl18r1I7F5OUfq3SpeiLSXTWwNOeayUbzyMtVJAeWosGv0f9mTKhgWf0s0Rs=\",\"success\":false}";
        Map mapTypes = JSON.parseObject(jsonS);
        String checksign = String.valueOf(mapTypes.get("sign"));
        String checkContent = assembelSignaturingData(mapTypes);
        System.out.println(checkContent);
        InputStream pubStream = SignatureProgram.class.getClassLoader().getResourceAsStream("服务器证书.crt");
        byte pubByte[] = new byte[2048] ;
        pubStream.read(pubByte);
        pubStream.close();
        X509Certificate x509Certificate = CryptoUtil.base64StrToCert(Base64Encrypt.getBASE64ForByte(pubByte));
        BouncyCastleProvider bouncyCastleProvider2 = new BouncyCastleProvider();
        Signature signatureCheck = Signature.getInstance("SHA1withRSA",bouncyCastleProvider2);
        boolean isOk = SignatureUtil.verify(signatureCheck,checkContent,checksign,x509Certificate.getPublicKey());

        System.out.println(isOk);
        //--------------验证翼支付签名demo------------
    }


    //顺序组装请求参数,用于签名/校验
    static String assembelSignaturingData(Map data) {
        StringBuilder sb = new StringBuilder();
        TreeMap<String, Object> treeMap = new TreeMap(data);
        for (Map.Entry<String, Object> ent : treeMap.entrySet()) {
            String name = ent.getKey();
            if (/* !"signType".equals(name) &&*/ !"sign".equals(name)) {
                sb.append(name).append('=').append(ent.getValue()).append('&');
            }
        }
        if (sb.length() > 0) {
            sb.setLength(sb.length() - 1);
        }
        return sb.toString();
    }
}

Base64Encrypt.java

package com.bestpay.mobilebiz.mapi.common.util;



import org.apache.commons.lang3.StringUtils;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * Base64加解密工具
 * @version 1.0.0
 * @time 2015/07/07
 */
public class Base64Encrypt {
    /***
     * BASE64加密
     * @param s 字符串
     * @return
     */
    public static String getBASE64(String s) {
        if(StringUtils.isEmpty(s)){
            return null;
        }
        Base64.Encoder encoder = Base64.getEncoder();
        try {
            byte [] bytes = s.getBytes("UTF-8");
            return encoder.encodeToString(bytes);
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }

    /***
     * BASE64加密
     * @param s  字节
     * @return
     */
	public static String getBASE64ForByte(byte[] s) {
		if (s == null)
            return null;
		return Base64.getEncoder().encodeToString(s);
	}

    /***
     * BASE64解密
     * @param s 字符串
     * @return
     * @throws Exception
     */
	public static byte[] getByteArrFromBase64(String s) throws Exception {
		if (s == null)
			return null;
		return Base64.getDecoder().decode(s);
	}

    /***
     * BASE64解密
     * @param s
     * @return
     */
	public static String getFromBASE64(String s) {
		Base64.Decoder decoder = Base64.getDecoder();
		try {
			byte[] b = decoder.decode(s);
			return new String(b);
		} catch (Exception e) {
			return null;
		}
	}

    /***
     *  将 BASE64 编码的字符串 s 进行解码
     * @param s  字符串
     * @param charset  编码
     * @return
     */
	public static String getFromBASE64(String s, String charset) {
        Base64.Decoder decoder = Base64.getDecoder();
		try {
			byte[] b = decoder.decode(s);
			return new String(b, charset);
		} catch (Exception e) {
			return null;
		}
	}
}

CryptoUtil.java

package com.bestpay.mobilebiz.mapi.common.util;

import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.encoders.Base64;
import sun.misc.BASE64Decoder;

import javax.crypto.Cipher;
import java.io.*;
import java.security.*;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;

/**
 * @Description:
 * @Date: 2017/8/7
 * @Moidfy by:
 */

public class CryptoUtil {

    private static BouncyCastleProvider bouncyCastleProvider;
    private static final Object LOCK = new Object();
    private static CertificateFactory factory = initFactory();

    private static CertificateFactory initFactory() {
        try {
            return CertificateFactory.getInstance("X.509");
        } catch (CertificateException var1) {
            throw new RuntimeException(var1);
        }
    }
    /**
     * @desc SHA256 加密公共类
     * @author liujianqun
     * @method getSHA256
     * @param  str 加密字符串
     * @return java.lang.String
     */
 public static String getSHA256(String str,String algorithm){
    MessageDigest messageDigest;
    String encdeStr = "";
    try {
        messageDigest = MessageDigest.getInstance(algorithm);
        byte[] hash = messageDigest.digest(str.getBytes("UTF-8"));
        encdeStr = Hex.encodeHexString(hash);
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
        return encdeStr;
    }

    public static String getSHA256Com(String str)
    {
        MessageDigest md = null;
        String result = "";
        try {
            md = MessageDigest.getInstance("SHA-256");
            md.update(str.getBytes("utf-8"));
            byte[] digest = md.digest();
            result=new String (Base64.encode(digest));

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
    public static byte[] getSHA256Byte(String str,String algorithm){
        MessageDigest messageDigest;
        try {
            messageDigest = MessageDigest.getInstance(algorithm);
            byte[] hash = messageDigest.digest(str.getBytes("UTF-8"));
            return hash;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    private static BouncyCastleProvider getInstanceProvider() {
        if(bouncyCastleProvider == null) {
            Object var0 = LOCK;
            synchronized(LOCK) {
                if(bouncyCastleProvider == null) {
                    bouncyCastleProvider = new BouncyCastleProvider();
                }
            }
        }

        return bouncyCastleProvider;
    }

    public static byte[] enDecryptByRsa(byte[] data, Key key, int mode) throws GeneralSecurityException {
        BouncyCastleProvider provider = getInstanceProvider();
        ByteArrayOutputStream outputStream = null;

        byte[] var21;
        try {
            outputStream = new ByteArrayOutputStream();
            Cipher cp = Cipher.getInstance("RSA/ECB/PKCS1Padding", provider);
            cp.init(mode, key);
            int blockSize = cp.getBlockSize();
            int blocksNum = (int)Math.ceil((double)data.length / (double)blockSize);
            int calcSize = blockSize;
            Object buffer = null;

            for(int i = 0; i < blocksNum; ++i) {
                if(i == blocksNum - 1) {
                    calcSize = data.length - i * blockSize;
                }

                byte[] var22 = cp.doFinal(data, i * blockSize, calcSize);

                try {
                    outputStream.write(var22);
                } catch (IOException var19) {
                    throw new GeneralSecurityException("RSA加/解密时出现异常", var19);
                }
            }

            var21 = outputStream.toByteArray();
        } finally {
            if(outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException var18) {
                }
            }

        }

        return var21;
    }
    public static X509Certificate base64StrToCert(String base64Cert) throws GeneralSecurityException {
        try {
            ByteArrayInputStream ex = new ByteArrayInputStream((new BASE64Decoder()).decodeBuffer(base64Cert));
            X509Certificate cert = (X509Certificate)factory.generateCertificate(ex);
            if(cert == null) {
                throw new GeneralSecurityException("将cer从base64转换为对象失败");
            } else {
                return cert;
            }
        } catch (IOException var3) {
            throw new GeneralSecurityException("将cer从base64转换为对象失败", var3);
        }
    }


    public static String signWithSHA2(InputStream fisP12, String pwd, String plainText)
    {
        String result ="";
        KeyStore inputKeyStore = null;
        try {
            if (fisP12 == null ||(pwd == null) || (plainText == null) || (pwd.equals("")) || (plainText.equals("")) ) {
                return  result;
            }
            inputKeyStore = KeyStore.getInstance("PKCS12");
            char[] inPassword = (pwd == null) ? null : pwd.toCharArray();
            inputKeyStore.load(fisP12, inPassword);
          //  fisP12.close();
            PrivateKey privateKey = (PrivateKey)inputKeyStore.getKey("conname", inPassword);
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(plainText.getBytes("utf-8"));
            byte[] digest = md.digest();
           // String digestText = new String(Base64.encode(digest));

            byte[] signData = RsaCipher.enDecryptByRsa(digest, privateKey, RsaCipher.EncryptMode.ENCRYPT);
            result = new String(Base64.encode(signData));
            return result;
/* 获取证书
   X509Certificate x509Certificate = (X509Certificate)inputKeyStore.getCertificate("conname");
            byte[] encoded = x509Certificate.getEncoded();
            String base64Cert = new String(Base64.encode(encoded));*/

        } catch (Exception e) {
            return "";
        }
    }
    public static  String getCert(InputStream fisP12, String pwd)
    {

        char[] inPassword = (pwd == null) ? null : pwd.toCharArray();
        try {
            KeyStore inputKeyStore = KeyStore.getInstance("PKCS12");
            inputKeyStore.load(fisP12, inPassword);
         //   fisP12.close();
            X509Certificate x509Certificate = (X509Certificate)inputKeyStore.getCertificate("conname");
            byte[] encoded = x509Certificate.getEncoded();
            return  new String(Base64.encode(encoded));

        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }

    }
    ///alias = conname
    public static KeyCertInfo fileStreamToKeyCertInfo(InputStream fisP12, String pwd, String keyStoreType, String alias){

        KeyCertInfo result = null;
        try {
            KeyStore inputKeyStore = KeyStore.getInstance(keyStoreType);
            char[] inPassword = (pwd == null) ? null : pwd.toCharArray();
            inputKeyStore.load(fisP12, inPassword);
            PrivateKey privateKey = (PrivateKey)inputKeyStore.getKey(alias, inPassword);
            X509Certificate x509Certificate = (X509Certificate)inputKeyStore.getCertificate(alias);
            byte[] encoded = x509Certificate.getEncoded();
            String base64Cert = new String(Base64.encode(encoded));
            result = new KeyCertInfo();
            result.setBase64Cert(base64Cert);
            result.setPrivateKey(privateKey);
            return result;
        } catch (Exception e) {
            return result;
        }
    }
    public static String signWithSHA2(String plainText,Key privateKey)
    {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA-256");
            md.update(plainText.getBytes("utf-8"));
            byte[] digest = md.digest();
            byte[] signData = RsaCipher.enDecryptByRsa(digest, privateKey, RsaCipher.EncryptMode.ENCRYPT);
            return new String(Base64.encode(signData));
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
    public static byte[] getSHA2Digest(String plainText)
    {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA-256");
            md.update(plainText.getBytes("utf-8"));
            byte[] digest = md.digest();
            return digest;
        }catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public static String signWithBase(byte[] digest,Key privateKey)
    {
        MessageDigest md = null;
        try {
            byte[] signData = RsaCipher.enDecryptByRsa(digest, privateKey, RsaCipher.EncryptMode.ENCRYPT);
            return new String(Base64.encode(signData));
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }


    public static PrivateKey byte2PrivateKey(byte[] src,String algorithm)
    {
        try {
            KeyFactory keyFactory = KeyFactory.getInstance(algorithm);//"RSA"
            PKCS8EncodedKeySpec pKCS8EncodedKeySpec =new PKCS8EncodedKeySpec(src);
            PrivateKey privateKey= keyFactory.generatePrivate(pKCS8EncodedKeySpec);
            return privateKey;

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
            return null;
        }
    }
    public static PublicKey byte2PublicKey(byte[] src,String algorithm)
    {
        try {
            KeyFactory keyFactory = KeyFactory.getInstance(algorithm);//"RSA"
            X509EncodedKeySpec x509KeySpec2 = new X509EncodedKeySpec(src);
            PublicKey privateKey= keyFactory.generatePublic(x509KeySpec2);
            return privateKey;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
            return null;
        }
    }
}

KeyCertInfo.java

package com.bestpay.mobilebiz.mapi.common.util;

import java.security.Key;

/**
 * Created by  on 2017/8/19.
 */
public class KeyCertInfo {
    public Key getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(Key privateKey) {
        this.privateKey = privateKey;
    }

    public String getBase64Cert() {
        return base64Cert;
    }

    public void setBase64Cert(String base64Cert) {
        this.base64Cert = base64Cert;
    }

    private Key privateKey;
    private String base64Cert;

}

RsaCipher.java

package com.bestpay.mobilebiz.mapi.common.util;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import sun.security.rsa.RSAPublicKeyImpl;

import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.Key;
import java.security.interfaces.RSAPublicKey;

public abstract class RsaCipher
{
    public static final Object LOCK = new Object();
    private static BouncyCastleProvider bouncyCastleProvider;

    public static byte[] enDecryptByRsa(byte[] data, Key key, int mode)
            throws GeneralSecurityException
    {
        byte[] var21;
        BouncyCastleProvider provider = getInstanceProvider();
        ByteArrayOutputStream outputStream = null;
        try
        {
            outputStream = new ByteArrayOutputStream();
            Cipher cp = Cipher.getInstance("RSA/ECB/PKCS1Padding", provider);
            cp.init(mode, key);
            int blockSize = cp.getBlockSize();
            int blocksNum = (int)Math.ceil((double) data.length / (double)blockSize);
            int calcSize = blockSize;
            Object buffer = null;

            for (int i = 0; i < blocksNum; ++i) {
                if (i == blocksNum - 1) {
                    calcSize = data.length - i * blockSize;
                }

                byte[] var22 = cp.doFinal(data, i * blockSize, calcSize);
                try
                {
                    outputStream.write(var22);
                } catch (IOException var19) {
                    throw new GeneralSecurityException("RSA加/解密时出现异常", var19);
                }
            }

            var21 = outputStream.toByteArray();
        } finally {
            if (outputStream != null)
                try {
                    outputStream.close();
                }
                catch (IOException var18)
                {
                }

        }

        return var21;
    }

    public static RSAPublicKey restoreKeyByModules(String modulesHex) throws GeneralSecurityException {
        BigInteger modules = new BigInteger(modulesHex, 16);
        BigInteger publicExponent = new BigInteger("65537");
        RSAPublicKeyImpl rsaPublicKey = new RSAPublicKeyImpl(modules, publicExponent);
        return rsaPublicKey;
    }

    public static byte[] enDecryptByRsa(byte[] data, Key key, EncryptMode mode) throws GeneralSecurityException {
        return enDecryptByRsa(data, key, 1 + mode.ordinal());
    }

    private static BouncyCastleProvider getInstanceProvider() {
        if (bouncyCastleProvider == null) {
            Object var0 = LOCK;
            synchronized (LOCK) {
                if (bouncyCastleProvider == null)
                    bouncyCastleProvider = new BouncyCastleProvider();
            }

        }

        return bouncyCastleProvider; }

    public static enum EncryptMode {
        ENCRYPT, DECRYPT;
    }
}

SignatureUtil.java文章来源地址https://www.toymoban.com/news/detail-664305.html

package com.bestpay.mobilebiz.mapi.common.util;

import org.apache.commons.codec.binary.Base64;

import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * @Author: 
 * @Description:
 * @Date: 2017/9/7
 * @Moidfy by:
 */
public class SignatureUtil {

    private static final String charcterCode = "UTF-8";
    /**
     * SHA256WithRSA签名
     * @param data
     * @param privateKey
     * @return
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     * @throws InvalidKeyException
     * @throws SignatureException
     * @throws UnsupportedEncodingException
     */
    public static String sign(Signature signature,String data, PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException,
            SignatureException, UnsupportedEncodingException {

        signature.initSign(privateKey);

        signature.update(data.getBytes(charcterCode));

        byte[] signBytes =  signature.sign();
        return  new String (org.bouncycastle.util.encoders.Base64.encode(signBytes));
    }

    public static boolean verify(Signature signature,String data, String sign, PublicKey publicKey) throws UnsupportedEncodingException {
        if(data == null || sign == null || publicKey == null){
            return false;
        }
        byte[] signBytes = org.bouncycastle.util.encoders.Base64.decode(sign.getBytes(charcterCode));
        try {
            signature.initVerify(publicKey);
            signature.update(data.getBytes(charcterCode));
            return signature.verify(signBytes);
        } catch (Exception e) {
            return false;
        }
    }

    /**
     * 二进制数据编码为BASE64字符串
     * @param bytes
     * @return
     */
    public static String encodeBase64(byte[] bytes){
        return new String(Base64.encodeBase64(bytes));
    }

    /**
     * BASE64解码
     * @param bytes
     * @return
     */
    public static byte[] decodeBase64(byte[] bytes) {
        byte[] result = null;
        try {
            result = Base64.decodeBase64(bytes);
        } catch (Exception e) {
            return null;
        }
        return result;
    }


    //顺序组装请求参数,用于签名/校验
    static String assembelSignaturingData(Map data) {
        StringBuilder sb = new StringBuilder();
        TreeMap<String, Object> treeMap = new TreeMap(data);
        for (Map.Entry<String, Object> ent : treeMap.entrySet()) {
            String name = ent.getKey();
            if (/* !"signType".equals(name) &&*/ !"sign".equals(name)) {
                sb.append(name).append('=').append(ent.getValue()).append('&');
            }
        }
        if (sb.length() > 0) {
            sb.setLength(sb.length() - 1);
        }
        return sb.toString();
    }
}

到了这里,关于java安全证书验证加密的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • java忽略证书验证(兼容http,https)

    日常上传、下载文件时可能有不需要验证证书的场景,比如证书过期、不正确之类的也可以正常的上传下载文件。 Java中使用https协议时,是通过X.509证书进行校验的。 首先我们先了解下什么是X.509证书。 X.509是公钥基础设施(PKI:Public Key Infrastructure)的标准格式,其实就是一

    2024年02月02日
    浏览(51)
  • Python爬虫学习日记——SSL证书验证

    问题引入:现在很多网站是使用HTTPS协议的,但是有些网站并没有设置好HTTPS证书,或者HTTPS的证书不被CA机构认可,这个时候访问这些网站就会报SSL证书错误 实例:访问https://www.ssr2.scrape.center/ 对于这种情况我们使用代码来爬取的效果 代码提示我们是SSL错误 因此如果就是要爬

    2024年02月16日
    浏览(55)
  • 根据验证过程,远程证书无效。未能为 SSL-TLS 安全通道建立信任关系。

    提示:这里简述项目相关背景: 例如:项目场景:vs2022,HttpClient调用接口出现错误(根据验证过程,远程证书无效。未能为 SSL/TLS 安全通道建立信任关系。) 缺少证书,需要在安装证书 点击安装证书=》本地计算机=》下列存储,选择受信任的根证书颁发机构,安装完成之后

    2024年03月22日
    浏览(56)
  • python实现对称加密、数字签名、数字证书颁发

    一.开发目的: 理解开源密码库实现的基本架构,熟悉对称算法的加解密函数封装与调用,并能能够利用开源设计接口进行二次封装,并实现一个界面友好,功能正确的采用对称算法的文件加解密工具。 二.开发环境: 硬件环境: 处理器:Intel®Core™i5-1035G1 CPU @1.00GHz 1.19GHz2

    2024年02月13日
    浏览(37)
  • 解决JAVA“无法验证证书。将不执行该应用程序。”提示

    笔者的一台电脑安装了Java 8 update 361。 需要使用UBNT网桥上的AirView应用(JAVA),但运行时提示: 应用程序出于安全原因被阻止 无法验证证书。 将不执行该应用程序。 名称:AirView 发行者:Ubiquiti Inc. 位置:http://172.16.x.x:80 笔者先前已经在控制面板——Java——安全——“例外

    2024年02月05日
    浏览(44)
  • HTTPS 请求中的证书验证详解(Python版)

    在网络通信中,HTTPS 是一种通过 SSL/TLS 加密的安全 HTTP 通信协议。证书在 HTTPS 中扮演着至关重要的角色,用于验证服务器身份并加密数据传输。本文将深入探讨 Python 中 HTTPS 请求中的证书相关内容,并提供详细的代码示例。 SSL/TLS 证书是一种由证书颁发机构签发的数字证明,

    2024年02月03日
    浏览(42)
  • 什么是HTTPS加密协议?HTTPS安全传输原理,SSL和TLS介绍,NGINX如何配置SSL证书

    HTTPS是超文本传输协议(HTTP)的安全版本。它使用SSL(安全套接层)或TLS(传输层安全)加密协议来保护数据传输的安全性和机密性,以防止未经授权的访问和窃听。HTTPS协议通常用于处理敏感信息,如在线支付或登录凭证等。可以通过URL的前缀来识别一个网站是否使用了H

    2024年02月03日
    浏览(58)
  • 数字证书的相关专业名词(中)---根证书和CRL,以及java中CRL的获取和验证方法

    上篇文章我们主要了解了PKI中的数字证书和PKCS,这篇文章我们主要了解一下根证书,以及OCSP和CRL。 在公钥基础设施(PKI)中,根证书是 整个数字证书体系的最高级别证书 。根证书由受信任的第三方机构(CA)颁发,用于验证其他证书以及建立信任链。 当您收到一个数字证

    2024年02月05日
    浏览(70)
  • java通过okhttp方式实现https请求的工具类(绕过证书验证)

    引入相关依赖包 2.1、跳过证书配置类 跳过证书配置类代码 2.2、okhttp方式的 https工具类 okhttp方式的 https工具类代码 测试代码 测试输出结果

    2024年01月23日
    浏览(86)
  • 使用Python的requests库发送HTTPS请求时的SSL证书验证问题

    问题描述 使用python的requests库去发送https请求,有时候不设置verify=False不报错,有时候又报错。 问题原因 使用Python的requests库发送HTTPS请求时,设置verify=False参数可以跳过SSL证书验证。默认情况下,requests库会验证SSL证书以确保请求的安全性。然而,在某些情况下,可能会出现

    2024年02月17日
    浏览(48)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包