zoukankan      html  css  js  c++  java
  • 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"));
                        });
                    });
    
    
            });
    
  • 相关阅读:
    (十一)QPainter绘图, QPixmap,QImage,QPicture,QBitmap
    (十)事件,定时器
    (九)自定义控件
    (八)控件介绍,QLable
    (六)QDialog,QMessageBox,QFileDialog,QColorDialog颜色,QFontDialog字体
    (七)布局
    (五)qt资源文件
    (四)窗口mainwindow
    (三)信号与槽
    JMeter学习-011-JMeter 后置处理器实例之
  • 原文地址:https://www.cnblogs.com/honk/p/14990255.html
Copyright © 2011-2022 走看看