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c2hlY2EgY2VydGlmaWNhdGUgY2hhaW4sbz1zaGVjYS5jb20wEQYIKoEcAcU4gRMEBTY2MDU1MBoGCCqBHAHFOIEUBA5RVDg0OTAyMzc0MDkyMzAJBgNVHRMEAjAAMEIGA1UdIAQ7MDkwNwYJKoEcAYbvOoEVMCowKAYIKwYBBQUHAgEWHGh0dHA6Ly93d3cuc2hlY2EuY29tL3BvbGljeS8wgeAGA1UdHwSB2DCB1TA3oDWgM4YxaHR0cDovL2xkYXAyLnNoZWNhLmNvbS9DQTIwMDExL1JBOTAzMS9DUkw1MTkxLmNybDCBmaCBlqCBk4aBkGxkYXA6Ly9sZGFwMi5zaGVjYS5jb206Mzg5L2NuPUNSTDUxOTEuY3JsLG91PVJBOTAzMSxvdT1DQTIwMDExLG91PWNybCxvPVVuaVRydXN0P2NlcnRpZmljYXRlUmV2b2NhdGlvbkxpc3Q/YmFzZT9vYmplY3RDbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludDANBgkqhkiG9w0BAQsFAAOCAQEAjQRnIYRE9SH4+leOjO9oUt++qhfefVzaZXdGQgxiUzIXv14vo9mls0COjz0YXoruEe6olh6X6rrdmaKrYw0iq2CJ3D1GkrFCutjX2P3r97Irale8w5J8hJ6dybd/rFZFZuTfYm7yWJLEcF+pAZXedGObwe4fOjS0J/A6KXqGsrdB/fJwvfHH5UIIWW3OihTr1TLEEuun/3oDbGdBDTud2+6tbiEN9daFV92TSko2DRQ/CisJoq5SCmI/dYZlAqeyr4jlLWHFfVUpHKu/lHtYCU0FsGyu9ixs4/YdBw/QIDj5oES9yf/FFDzfTnS8twa8rRJKWdUKKa9sYEeJtVQ==";
CertificateFactory cf = CertificateFactory.getInstance("X.509", new BouncyCastleProvider());
X509Certificate certificate = (X509Certificate) cf
.generateCertificate(new ByteArrayInputStream(Base64Utils.decode(rootCert)));
当然你也可以通过X509文件形式去生成,代码如下:
public static void main(String[] args) throws Exception {
String certificateFileName = "C:\Users\Administrator\Downloads\user.cer";
FileInputStream inputStream = new FileInputStream(certificateFileName);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate certificate = (X509Certificate) certificateFactory.generateCertificate(inputStream);
}
这里说一下X509文件一般使用的后缀:
X509证书文件一般使用以下文件后缀名:
这些后缀名的具体使用取决于证书文件所包含的数据类型和编码方式。例如,.pem格式的证书是以Base64编码的ASCII文本格式,.crt格式的证书通常是PEM编码的,而.cer格式的证书可以是DER编码或PEM编码。
X509Certificate.getSerialNumber()
getSerialNumber()方法是用于获取证书的序列号的方法。
X.509证书的序列号是一个唯一标识符,用于区分不同证书之间的差异。通常情况下,证书颁发机构(CA)会为每个证书生成一个唯一的序列号,并将这个序列号嵌入到证书中。在使用证书进行身份验证时,可以通过比较证书序列号来确定证书是否有效,以及它是否由可信的CA签发。
getSerialNumber()方法返回一个BigInteger对象,该对象包含证书的序列号。开发者可以使用这个方法来检索证书的序列号,并进一步对证书进行身份验证和授权操作。
总之,X509Certificate.getSerialNumber()方法是一个用于获取X.509证书序列号的实用方法,在进行证书验证和授权操作时非常有用。
既然说到了序列号,我们额外提一嘴。
不同CA对序列号的生成方式各不相同,我们一般是通过CertificateSerialNumber
去创建一个序列号,该类接收一个BigInteger类型的参数。例如下面的例子就创建一个大数随机数作为序列号。
下面是例子演示
String rootCert = "MIIDyzCCArOgAwIBAgIPZ1aEiQODAHdFOTcDiGBkMA0GCSqGSIb3DQEBCwUAMGIxCzAJBgNVBAYTAkNOMTkwNwYDVQQKDDBHbG9iYWwgRGlnaXRhbCBDeWJlcnNlY3VyaXR5IEF1dGhvcml0eSBDby4sIEx0ZC4xGDAWBgNVBAMMD0dEQ0EgUHVibGljIENBMTAeFw0yMzA0MDYxNjAwMDBaFw0yNDA0MDcwMzAzMjhaMEUxCzAJBgNVBAYTAkNOMRIwEAYDVQQLDAnlkLTlhavkuIMxIjAgBgNVBAMMGeWQtOWFq+S4g0AxMjPvvIjmtYvor5XvvIkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDWevk0uTatu9AJR+iPmyXaDdOdBEH0k6iisbRXgyg20mxtmABKY2vGyX27e/SS7kN45otADrZNa5GXqtyteN6FQ5TGDoZ2gw0krpAX3dUedYEPAFLTFh77PyC1CORq5AaXZvZ+iSW4sny7iUGA3S3cGMu6a2/Ufcu8uauj2+BjvegG8ggbYKYCM3er+1qFuMhTigowKH0f8hdW3TWxxmHbxkwSs4YG1t1tPgBt+YlGtXiV6WWzfY/VhRQD5PyyKe+iQWBHQlJqx4cgpPXfEVGDTDj1HfiUtpXSl9e569tRHrCOhFdnuR6Oqc1u2wXx6pWp3Gg8B8XhRf+i632+bdMxAgMBAAGjgZowgZcwHQYDVR0OBBYEFHh/R7OrwnzCOmpL+B/Wxa9lHf33MAsGA1UdDwQEAwIGwDAfBgNVHSMEGDAWgBSVTRMfayGRCW8WEoplvAtWCxFryDApBgUqVgsHAQQgMR6AHFFMMEFGV01JWDhOUlpUS2VvZjljWHN2YnZ1OD0wHQYFKlYVAQMEFAwSMDc1Njg0ODkwMzgzMDA3NzQ0MA0GCSqGSIb3DQEBCwUAA4IBAQBKwcgCKJ3UAJZLei40cZ59lpxPPHf6dsal1fUn+HAVVnK/zi/N2Ybe7TeJtgdSwrd3n7PiKbvmCtsQu9hudkGibFkpeSu9yRLCTNa7+onnWucDFXO3OFhFrLYyZ28Z2Tli9bTnbHuoz4mJZBeqkisTrylNF235vDTSYSMgsiIRWIQRwFqlRZY7hIAkxlivYGjgqjzKOVrAkgj5Vg5EoCdIyKncQ0vyxDEb9IiaCQHlfcott5kFHrFt0rgDqUxSDZw0BOxk9G2bGLZ2q7i1LHnKOMoMNi5FvrY7ZfDcsVNzANSJ9KywAX2J9WXJFjNfhWjlEzuJjIN5Zim4QSDM3Cjv";
CertificateFactory cf = CertificateFactory.getInstance("X.509", new BouncyCastleProvider());
X509Certificate certificate = (X509Certificate) cf
.generateCertificate(new ByteArrayInputStream(Base64Utils.decode(rootCert)));
System.out.println(certificate.getSerialNumber());
get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wrd3n7PiKbvmCtsQu9hudkGibFkpeSu9yRLCTNa7+onnWucDFXO3OFhFrLYyZ28Z2Tli9bTnbHuoz4mJZBeqkisTrylNF235vDTSYSMgsiIRWIQRwFqlRZY7hIAkxlivYGjgqjzKOVrAkgj5Vg5EoCdIyKncQ0vyxDEb9IiaCQHlfcott5kFHrFt0rgDqUxSDZw0BOxk9G2bGLZ2q7i1LHnKOMoMNi5FvrY7ZfDcsVNzANSJ9KywAX2J9WXJFjNfhWjlEzuJjIN5Zim4QSDM3Cjv";
CertificateFactory cf = CertificateFactory.getInstance("X.509", new BouncyCastleProvider());
X509Certificate certificate = (X509Certificate) cf
.generateCertificate(new ByteArrayInputStream(Base64Utils.decode(rootCert)));
System.out.println(certificate.getIssuerDN());
可能有些小伙伴会发现除了getIssuerDN()
之外还有一个getIssuerX500Principal()
方法,其实大家运行后会发现两者返回的DN信息其实是一致的,只是顺序可能不一样。他们两个方法的区别就在于返回类型的不同,getIssuerDN()
返回类型为Principal,而getIssuerX500Principal()
返回X500Principal,它是Java安全API中定义的一种标准类型的X.500 Principal类型。这个对象也可以被用于进一步处理和解析DN中的属性,但是其主要优势是可以直接用于与其他Java API中的X.500 Principal类型集成。
X500Principal可以看作是Principal的一个具体实现,专门用于处理X.500格式的DN。它包含了X.500格式的字符串表示形式,并提供了一些与X.500 DN相关的方法,例如:getName()、getEncoded()等。
理解了这个,后面的getSubjectDN()和getSubjectX500Principal()的区别想必也不难理解
getSubjectDN()
和getSubjectX500Principal()
X509Certificate.getSubjectDN()
是 Java 中 X.509 证书(一种常见的公钥证书格式)类 X509Certificate 的一个方法。它返回证书主体的 Distinguished Name(简称 DN),即证书中标识持有者身份信息的部分。和之前的getIssueDn不同的是,前者是证书持有者,后者是证书颁发者。
例如,假设 A 公司的网站使用了一张由 B CA 签发的 X.509 数字证书,那么该证书的 subject DN 中会包含 A 公司的相关信息,issuer DN 中会包含 B CA 的相关信息。调用 getSubjectDN() 方法可以获取到 A 公司的身份信息,调用 getIssuerDN() 方法可以获取到 B CA 的身份信息。
DN 通常由多个相互独立的字段组成,这些字段采用键值对的方式描述了证书持有者的重要信息。例如,一个包含 CN、OU、O、L、ST、EMAILADDRESS 和 C 字段的 DN 可以表示一个具体的人或实体,如下所示:
CN=xxx@xxx, OU=Organize Unit, O=Organize Ltd., L=city, ST=privince, EMAILADDRESS= [email protected],C=CN
其中,CN 表示 Common Name,即常用名称,代表证书持有者的姓名或实体名;OU 表示 Organizational Unit,即组织单位,代表证书持有者所在的组织或部门;O 表示 Organization,即组织机构,代表证书持有者所属的公司或机构;L 表示 Locality,即所在地,代表证书持有者所在的城市或地区;ST 表示 State,即省份或州,代表证书持有者所在的省份或州;EMAILADDRESS 表示邮件地址;C 表示 Country,即国家或地区,代表证书持有者所在的国家或地区。
通过调用 X509Certificate.getSubjectDN() 方法,我们可以获取到证书中标识持有者身份信息的所有字段及其值,以便进行身份验证或授权等操作。
而getSubjectX500Principal()
和getIssuerX500Principal()
本质上是一样的,这里不做赘述
以下是测试代码:
public static void main(String[] args) throws GeneralSecurityException, IOException, OperatorException, OCSPException {
String verifyCert = "MIIFuDCCBKCgAwIBAgIQche7n/HhSQ+guIZEOjNvGzANBgkqhkiG9w0BAQsFADAzMQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxETAPBgNVBAMMCFNIRUNBIEcyMB4XDTIzMDIwNTE3MDQ0MVoXDTIzMDUwNjE1NTk1OVowTzELMAkGA1UEBhMCQ04xGzAZBgNVBAoMEueUteWtkOetvueroOWJjeWPsDEjMCEGA1UEAwwa5rWL6K+VMDEwMTExMUA4NCoqKioqKioqMjMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCHJ8088uY9p4XD77TrLu3h0tB5O4Xp32hW4zNttjHmhoXai7wngFooNXDzGwj9JnM99VE+qjQzkr8Th9pyIYeTk5eLTMmmMEo/p42uiHyGbTtn8B2g3wmPTApu2S4+MAkNbvPD5VDEfMb+1e/7oN39NTZv1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ZT9vYmplY3RDbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludDANBgkqhkiG9w0BAQsFAAOCAQEAjQRnIYRE9SH4+leOjO9oUt++qhfefVzaZXdGQgxiUzIXv14vo9mls0COjz0YXoruEe6olh6X6rrdmaKrYw0iq2CJ3D1GkrFCutjX2P3r97Irale8w5J8hJ6dybd/rFZFZuTfYm7yWJLEcF+pAZXedGObwe4fOjS0J/A6KXqGsrdB/fJwvfHH5UIIWW3OihTr1TLEEuun/3oDbGdBDTud2+6tbiEN9daFV92TSko2DRQ/CisJoq5SCmI/dYZlAqeyr4jlLWHFfVUpHKu/lHtYCU0FsGyu9ixs4/YdBw/QIDj5oES9yf/FFDzfTnS8twa8rRJKWdUKKa9sYEeJtVQ==";
CertificateFactory cf = CertificateFactory.getInstance("X.509", new BouncyCastleProvider());
X509Certificate certificate = (X509Certificate) cf
.generateCertificate(new ByteArrayInputStream(Base64Utils.decode(verifyCert)));
System.out.println(certificate.getSubjectDN());
System.out.println(certificate.getSubjectX500Principal());
}
getNotBefore()
和getNotAfter()
getNotBefore()和getNotAfter()是Java中X.509证书类(java.security.cert.X509Certificate)的方法,用于获取证书的生效日期和过期日期。两者均返回Date类型
getNotBefore()方法返回证书的生效日期,它表示自1970年1月1日00:00:00 GMT以来的毫秒数。这个时间点之前,证书被认为是无效的。例如,如果getNotBefore()返回的值是1618476000000,那么证书的生效日期是2021年4月15日00:00:00 GMT。
getNotAfter()方法返回证书的过期日期,它也表示自1970年1月1日00:00:00 GMT以来的毫秒数。这个时间点之后,证书将被认为是无效的。例如,如果getNotAfter()返回的值是1649992800000,那么证书的过期日期是2023年4月14日23:59:59 GMT。
这些方法可用于验证证书是否在其生命周期内,并且可以帮助确定何时需要更新证书。
下面是示例代码:
public static void main(String[] args) throws GeneralSecurityException, IOException, OperatorException, OCSPException {
String verifyCert = "MIIFuDCCBKCgAwIBAgIQche7n/HhSQ+guIZEOjNvGzANBgkqhkiG9w0BAQsFADAzMQswCQYDVQQGE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AHFOIEUBA5RVDg0OTAyMzc0MDkyMzAJBgNVHRMEAjAAMEIGA1UdIAQ7MDkwNwYJKoEcAYbvOoEVMCowKAYIKwYBBQUHAgEWHGh0dHA6Ly93d3cuc2hlY2EuY29tL3BvbGljeS8wgeAGA1UdHwSB2DCB1TA3oDWgM4YxaHR0cDovL2xkYXAyLnNoZWNhLmNvbS9DQTIwMDExL1JBOTAzMS9DUkw1MTkxLmNybDCBmaCBlqCBk4aBkGxkYXA6Ly9sZGFwMi5zaGVjYS5jb206Mzg5L2NuPUNSTDUxOTEuY3JsLG91PVJBOTAzMSxvdT1DQTIwMDExLG91PWNybCxvPVVuaVRydXN0P2NlcnRpZmljYXRlUmV2b2NhdGlvbkxpc3Q/YmFzZT9vYmplY3RDbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludDANBgkqhkiG9w0BAQsFAAOCAQEAjQRnIYRE9SH4+leOjO9oUt++qhfefVzaZXdGQgxiUzIXv14vo9mls0COjz0YXoruEe6olh6X6rrdmaKrYw0iq2CJ3D1GkrFCutjX2P3r97Irale8w5J8hJ6dybd/rFZFZuTfYm7yWJLEcF+pAZXedGObwe4fOjS0J/A6KXqGsrdB/fJwvfHH5UIIWW3OihTr1TLEEuun/3oDbGdBDTud2+6tbiEN9daFV92TSko2DRQ/CisJoq5SCmI/dYZlAqeyr4jlLWHFfVUpHKu/lHtYCU0FsGyu9ixs4/YdBw/QIDj5oES9yf/FFDzfTnS8twa8rRJKWdUKKa9sYEeJtVQ==";
CertificateFactory cf = CertificateFactory.getInstance("X.509", new BouncyCastleProvider());
X509Certificate certificate = (X509Certificate) cf
.generateCertificate(new ByteArrayInputStream(Base64Utils.decode(verifyCert)));
System.out.println(DateUtil.format(certificate.getNotBefore(),"yyyy-MM-dd HH:mm:ss"));
System.out.println(DateUtil.format(certificate.getNotAfter(),"yyyy-MM-dd HH:mm:ss"));
}