mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add cert package
This commit is contained in:
parent
dea810e933
commit
fe9a5dea14
@ -26,6 +26,7 @@ import org.dromara.hutool.core.util.RandomUtil;
|
||||
import org.dromara.hutool.crypto.asymmetric.AsymmetricAlgorithm;
|
||||
import org.dromara.hutool.crypto.bc.ECKeyUtil;
|
||||
import org.dromara.hutool.crypto.bc.SM2Constant;
|
||||
import org.dromara.hutool.crypto.cert.CertUtil;
|
||||
import org.dromara.hutool.crypto.provider.GlobalProviderFactory;
|
||||
import org.dromara.hutool.crypto.symmetric.SymmetricAlgorithm;
|
||||
|
||||
|
@ -16,17 +16,13 @@
|
||||
|
||||
package org.dromara.hutool.crypto.bc;
|
||||
|
||||
import org.dromara.hutool.core.io.stream.FastByteArrayOutputStream;
|
||||
import org.dromara.hutool.core.io.IORuntimeException;
|
||||
import org.bouncycastle.asn1.ASN1Encodable;
|
||||
import org.bouncycastle.asn1.ASN1Encoding;
|
||||
import org.bouncycastle.asn1.ASN1InputStream;
|
||||
import org.bouncycastle.asn1.ASN1Object;
|
||||
import org.bouncycastle.asn1.ASN1Sequence;
|
||||
import org.bouncycastle.asn1.BERSequence;
|
||||
import org.bouncycastle.asn1.DERSequence;
|
||||
import org.bouncycastle.asn1.DLSequence;
|
||||
import org.bouncycastle.asn1.*;
|
||||
import org.bouncycastle.asn1.util.ASN1Dump;
|
||||
import org.bouncycastle.asn1.x500.X500Name;
|
||||
import org.bouncycastle.asn1.x500.X500NameBuilder;
|
||||
import org.bouncycastle.asn1.x500.style.BCStyle;
|
||||
import org.dromara.hutool.core.io.IORuntimeException;
|
||||
import org.dromara.hutool.core.io.stream.FastByteArrayOutputStream;
|
||||
import org.dromara.hutool.crypto.CryptoException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -119,4 +115,27 @@ public class ASN1Util {
|
||||
public static String getDumpStr(final InputStream in) {
|
||||
return ASN1Dump.dumpAsString(decode(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成X500Name信息
|
||||
*
|
||||
* @param C Country Name (国家代号),eg: CN
|
||||
* @param ST State or Province Name (洲或者省份),eg: Beijing
|
||||
* @param L Locality Name (城市名),eg: Beijing
|
||||
* @param O Organization Name (可以是公司名称),
|
||||
* @param OU Organizational Unit Name (可以是单位部门名称)
|
||||
* @param CN Common Name (服务器ip或者域名),eg: 192.168.30.71 or www.baidu.com
|
||||
* @return X500Name
|
||||
*/
|
||||
public static X500Name createX500Name(final String C, final String ST, final String L,
|
||||
final String O, final String OU, final String CN) {
|
||||
return new X500NameBuilder()
|
||||
.addRDN(BCStyle.C, C)
|
||||
.addRDN(BCStyle.ST, ST)
|
||||
.addRDN(BCStyle.L, L)
|
||||
.addRDN(BCStyle.O, O)
|
||||
.addRDN(BCStyle.OU, OU)
|
||||
.addRDN(BCStyle.CN, CN)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.dromara.hutool.crypto;
|
||||
package org.dromara.hutool.crypto.cert;
|
||||
|
||||
import org.dromara.hutool.core.io.file.FileUtil;
|
||||
import org.dromara.hutool.crypto.CryptoException;
|
||||
import org.dromara.hutool.crypto.KeyStoreUtil;
|
||||
import org.dromara.hutool.crypto.provider.GlobalProviderFactory;
|
||||
|
||||
import java.io.File;
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Hutool Team and hutool.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 证书相关工具类
|
||||
*
|
||||
* @author Looly
|
||||
* @since 6.0.0
|
||||
*/
|
||||
package org.dromara.hutool.crypto.cert;
|
Loading…
x
Reference in New Issue
Block a user