• OpenSSL证书转PFX


    OpenSSL证书转pfx

    pem证书转pfx证书分两种,一种带ca证书转换,一种不带ca证书转换

    1. pem转pfx(不带ca证书)

    以test.pem转test.pfx为例

    openssl rsa -in test.pem -out test.key
    openssl x509 -in test.pem -out test.crt
    openssl pkcs12 -export -out test.pfx -inkey test.key -in test.crt
    

    2. pem转pfx(带ca证书)

    以test.pem和ca.crt(ca.pem)转 test_ca.pfx为例

    openssl rsa -in test.pem -out test.key
    openssl x509 -in test.pem -out test.crt
    openssl pkcs12 -export -out test_ca.pfx -inkey test.key -in test.crt -CAfile ca.crt
    

    3. 如果ca证书为pem格式

    openssl pkcs12 -export -out test_ca.pfx -inkey test.key -in test.crt -CAfile ca.pem
    openssl pkcs12 -export -out client-ca.pfx -inkey client-key.pem -in client-cert.pem -CAfile cacert.pem
    openssl pkcs12 -export -out client.pfx -inkey client-key.pem -in client-cert.pem
    

    主要解决实际场景问题

    asp.net https使用Cloudflare 签名证书

    1. 首先,到 Cloudflare 申请证书.
      证书申请

    2. 然后 下载/复制 pem格式证书到本地.

    3. (可选)下载Cloudflare官方的CA证书.

      根据你申请证书的加密方式,选择对应的CA证书:

    1. 下载Windows平台最新编译的OpenSSL

    2. 执行OpenSSL命令

    openssl pkcs12 -export -out Cloudflare.pfx -inkey key.pem -in certificate.pem -password pass:"123456"
    
    openssl pkcs12 -export -out Cloudflare2.pfx -inkey key.pem -in certificate.pem -CAfile origin_ca_rsa_root.pem -password pass:"123456"
    
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>()
                    .UseKestrel(options =>
                    {
                        options.AddServerHeader = false;
                        options.ListenAnyIP(80);
                        options.ListenAnyIP(443, lopr =>
                        {
                            lopr.UseHttps(
                                new System.Security.Cryptography.X509Certificates.X509Certificate2(
                                    "Cloudflare.pfx", "123456"));
                        });
                    });
    
    
            });
    
  • 相关阅读:
    ACM ICPC 2008–2009 NEERC MSC A, B, C, G, L
    POJ 1088 滑雪 DP
    UVA 11584 最短回文串划分 DP
    POJ 2531 Network Saboteur DFS+剪枝
    UVa 10739 String to Palindrome 字符串dp
    UVa 11151 Longest Palindrome 字符串dp
    UVa 10154 Weights and Measures dp 降维
    UVa 10271 Chopsticks dp
    UVa 10617 Again Palindrome 字符串dp
    UVa 10651 Pebble Solitaire 状态压缩 dp
  • 原文地址:https://www.cnblogs.com/honk/p/14990255.html
Copyright © 2020-2023  润新知