【问题标题】:curl - OpenSSL error error:0308010C:digital envelope routines::unsupportedcurl - OpenSSL 错误 error:0308010C:digital envelope routines::unsupported
【发布时间】:2022-11-13 05:17:14
【问题描述】:

我尝试在 Windows 上使用 curl 来发布时间戳请求。需要身份验证,所以我使用 p12 文件。我收到错误消息,但 p12 文件的密码是正确的。

命令:

curl --insecure --cert-type P12 --cert my.p12:mypassword -X POST -d @mytest.req <myTSURL>

错误信息:

curl: (58) 无法解析 PKCS12 文件,检查密码,OpenSSL 错误 错误:0308010C:数字信封例程::不支持

卷曲-V

curl 7.83.1 (x86_64-pc-win32) libcurl/7.83.1 OpenSSL/3.0.2 (Schannel) zlib/1.2.12 brotli/1.0.9 libidn2/2.3.2 libssh2/1.10.0 nghttp2/1.47.0 ngtcp2/0.5.0 nghttp3/0.4.1 libgsasl/1.10.0
Release-Date: 2022-05-11
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli gsasl HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL SSPI TLS-SRP UnixSocket

【问题讨论】:

    标签: windows curl openssl pkcs#12


    【解决方案1】:

    Meta:这不是真正的编程或开发,在超级用户或 security.SX 上可能会更好,但随着 OpenSSL 3.0 的传播,这个问题可能会变得更加普遍,我想得到答案。

    默认情况下,OpenSSL 3.0.x 不支持旧的/不安全的算法,但直到最近大多数创建 PKCS12(包括 OpenSSL 1.x.x)的软件都将这种算法用于 certbag,即使用 RC2 的 PKCS12 定义的 PBE- 40 - 有些仍然至少有时会这样做,例如默认情况下的 Windows 10 证书导出对话框。要检查这个

    openssl pkcs12 -in my.p12 -info -nokeys -nocerts 
    # in 3.0.x add -provider legacy or just -legacy
    # to avoid prompt use -password or -passin, see man pages
    

    我希望输出将包括

    PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
    

    查看您的 curl 是否可以选择指定 OpenSSL 3.0.x 提供程序,如果有,请指定“旧版”。否则,将您的 pkcs12 转换为

    # 3.0.x
    openssl pkcs12 -in old -nodes -provider legacy | openssl pkcs12 -export -out new
    # or slightly simpler
    openssl pkcs12 -in old -nodes -legacy | openssl pkcs12 -export -out new
    
    # 1.x.x
    openssl pkcs12 -in old -nodes | openssl pkcs12 -export -descert -out new 
    

    转换会丢失现有文件中设置的任何“友好名称”。对于 curl 和可能的大多数其他程序,这无关紧要,但如果你想将同一个文件与友好名称的东西一起使用问题,在-export 部分添加-name $name

    【讨论】:

    • 输出为:MAC: sha1, Iteration 1024 MAC length: 20, salt length: 20 PKCS7 Data Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 1024 PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 1024 Error outputting keys and certificates B00E0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:cryptoevpevp_fetch.c:349:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()'
    • @dave_thompson_085 感谢您的回答,但是请参阅stackoverflow.com/a/59934697/3872647 我认为您的证书转换命令不起作用,除非有办法让 openssl 先发出密钥,然后再发出证书
    【解决方案2】:

    我在使用 OpenVPN 时遇到了同样的错误。我能够通过在 /etc/ssl/openssl.cnf 配置文件中添加或取消注释以下行来修复它:

       openssl_conf = openssl_init
       
       [openssl_init]
       providers = provider_sect
       
       [provider_sect]
       default = default_sect
       legacy = legacy_sect
       
       [default_sect]
       activate = 1
       
       [legacy_sect]
       activate = 1
    

    这是基于OpenSSL WIKI的信息

    【讨论】:

      猜你喜欢
      • 2023-01-25
      • 2023-01-26
      • 2023-02-13
      • 2021-10-26
      • 2022-11-08
      • 2022-12-15
      • 2023-01-24
      • 2022-12-28
      • 2016-09-04
      相关资源
      最近更新 更多