前置条件 : 已经购买或租用的域名
操作步骤
- 打开申请页面
- 然后按照顺序填写上面的内容
- 然后就签发成功了
好了下面是具体的步骤
操作步骤
-
打开页面
-
步骤一选择
Let's Encrypt
-
步骤二域名填写
你的域名
-
证书私钥填写下面的证书私钥或者自己生成RSA2048的私钥也行
-
ACME账户私钥填写下面的账户私钥或者自己生成RSA2048的私钥也行
-
邮箱填写自己的邮箱
-
然后确认之后进入第二步
-
域名管理添加子域名和text记录
-
验证通过之后下载key文件和证书文件
10.然后就可以得到一个服务器站点证书了 -
需要pfx的可以通过工具将私钥和证书合并成pfx
更新证书时步骤和上面一致
可以将账户私钥进行保存,方便更新使用
生成pfx
package com.example.pfx;import com.example.demo.cipher.util.PfxUtil;import org.bouncycastle.util.encoders.Base64;import org.bouncycastle.util.encoders.Hex;import org.junit.jupiter.api.Test;import java.security.PrivateKey;import java.security.cert.Certificate;/** * @author lidg * @date 2023/9/11 12:08 * @desc */public class PfxTest { @Test public void genPfxTest() throws Exception { // 上面的证书私钥,p8格式的私钥 String privateKeyStr = ""; // 签发出来的证书 String cert = ""; // pfx的保护密码 String passwd = "12345678"; // 解析私钥 PrivateKey privateKey = PfxUtil.parsePrivateKey(Base64.decode(privateKeyStr)); // 解析证书 Certificate certificate = PfxUtil.parseCert(Base64.decode(cert)); // 生成pfx PfxUtil.genPfx(privateKey, certificate, passwd, "myPfx.pfx"); }}
PfxUtil.java
/** * @author lidg * @date 2023/9/11 14:39 * @desc */public class PfxUtil { static { // 注册bc库 Security.addProvider(new BouncyCastleProvider()); } public static void genPfx(PrivateKey privateKey, Certificate certificate, String pwd, String outPath) throws Exception { try (FileOutputStream fos = new FileOutputStream(outPath)) { // 创建一个密钥存储对象,指定类型为PKCS#12 KeyStore keyStore = KeyStore.getInstance("PKCS12"); // 初始化密钥存储对象并设置口令 keyStore.load(null, null); // 将私钥、公钥和证书添加到密钥存储对象中,指定别名和口令 // 指定一个别名 String alias = "myAlias"; keyStore.setKeyEntry(alias, privateKey, pwd.toCharArray(), new Certificate[]{certificate}); // 将密钥存储对象保存到文件或输出流中 keyStore.store(fos, pwd.toCharArray()); } catch (Exception e) { throw new Exception("构造pfx失败", e); } } public static PrivateKey parsePrivateKey(byte[] p8PrivateBytes) throws Exception { // 创建一个私钥规范对象 PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(p8PrivateBytes); // 创建一个密钥工厂对象 KeyFactory keyFactory = KeyFactory.getInstance("RSA"); // 生成一个私钥对象 PrivateKey privateKey = keyFactory.generatePrivate(keySpec); // 返回私钥对象 return privateKey; } public static Certificate parseCert(byte[] x509CertBytes){ try { // 创建一个证书工厂对象,指定类型为X.509 CertificateFactory cf = CertificateFactory.getInstance("X.509"); // 生成一个证书对象 Certificate certificate = cf.generateCertificate(new ByteArrayInputStream(x509CertBytes)); // 返回证书对象 return certificate; } catch (CertificateException e) { System.out.println("解析失败"); throw new RuntimeException(e); } }}
站点证书密钥对: RSA2048
-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn1k/AMic9LR2GfyVUc1NUYpVEjnXf+UiI6EDSZVbsyAUmh9mSACIR+4UyyfUUaxHTzyUG7RtuNKVGGEx6dCg5VKBoid9XfpeGJP7TEhYGBHqhGCv86yrStxsFojHO1HcEP5Gs0lXGZgDH7s6/NLO+KaCLu1MV4z7JBy/izl8nykBGUO2cykaY4j/4oGToC7Fgj8i8og72OcTZtGmwba76eMgux/IW9poHyhl/EF/mjSs+FQhvFkY4egGNk8g36Rp3bLI4YGWGXnc3UwRLGTL1D1vTjxcgd3ABf33joHMznkfuOnCMpkFxXgJo9S4BUrlPNnGSN2zX3Tzn4CWe23vQQIDAQAB-----END PUBLIC KEY----------BEGIN PRIVATE KEY-----MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfWT8AyJz0tHYZ/JVRzU1RilUSOdd/5SIjoQNJlVuzIBSaH2ZIAIhH7hTLJ9RRrEdPPJ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ggIxjmuT2Iz3zCwb1wxdBiRcKEBakvnyD/+EBvoTjf1zMt76CYO9kLXvp/7HHsr/aGKLP+Bw149t0w7KNXK0gmkbF0BJk1J0a4K2DcfgohcxtlT1uCb/6GtR9B7QKBgQDKEmiZQejixHIUT37hw8UO2PP5z/T27OKUFWNEaya0ec3rUhjtsoX1dZi6YRWiNw0X/ZtUQIREUIHWvkIDJhs0QTZwUYljcP6J155YawSCm/sRAREEde9Y5MYoox1rp4enfFIvecE98tp06rc5ybvVmlPoDSxpFgEppixDysiOFwKBgQDGJ4tqXMnXICC6ihCy5a7N103k7FOjIlrQvuPbcuak2EbktGgkuns24e/Kp4jbSdFUA8GGaVAGq3yJ2RVqTICitGVCZUMBIPYJfkfzEO80rz9Xj/UFwkQ5YrAPMhabQpuqBC7qpc6tTF70RIUpPXVfebPAVN4eqkPFb+MpdRjkxwKBgGwLv8YCieWGqIDXqL5KkTlJI9r1KMRHETeg3/0bVgy1/DbRJOcjx6DhihJOCuU7jlK/lahM/uwQJ/yMqntIis8790HDNzTmnBNUKSSZxEWZ5XrIGTNLY/kiChp8bSS85TnWrZMZBQx8p/ZP8jyB819ZL3gqYw6lZ2W/pndxHB9tAoGANW3eOpywU9A24vVtUT97JceDGlHar2cJA7Yk7DwMErC6VNqMJjMeHAtJw+Puk+pQhg3JNbvZtyKwHt8o1hOwr65ii0eQjJJdpOum7NRJG3SRaMPJNndOPAbvH/nKfKy2Gl6sY9q3YqTwCX8cRKVsq4S+QgLgLXaNdYQYxUnsn2sCgYAo0HZD/gGSkXpnd4AX9o5okKd9axVzD7dR/jjduxI9RgXcgjnyw8znHBLlsaOUYezaQ+wveHv+vWRtiB1wsvsF1zu601485CYZ0iG06E9TdyBbt2VC3NTP5KNsfTBE7LHpK1XPtKByeuKawiEB07MbII1esRSxKgKzNdFE2mQF+g==-----END PRIVATE KEY-----
生成密钥对的网站
扩展
需要注册才能申请ssl证书的网站