【问题标题】:How to pass a certificate file and a secret key - Feign Client如何传递证书文件和密钥 - Feign Client
【发布时间】:2019-11-05 20:01:24
【问题描述】:

我需要通过 https 进行第三方 rest api 调用。我想在 Spring Boot 应用程序中使用 feign 客户端。我对 feign 客户端以及如何使用它进行 api 调用有一个想法。但我不确定如何传递证书文件和密钥。下面是我想使用 feign 客户端实现的示例 python 代码提取。可以帮我合并标记为 ** 的代码。

certificate_file = 'example.com.pem'
certificate_secret= 'exampleserver.key'

**context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.load_cert_chain(certificate_file, certificate_secret)
conn = http.client.HTTPSConnection("hostname", context=context)**
payload = "{<JSON payload>}"

headers = {
    'Content-Type': "application/json",
    }

conn.request("POST", "api/example/setInfo", payload, headers)

【问题讨论】:

    标签: openssl ssl-certificate feign openfeign


    【解决方案1】:

    将私钥和公钥合并到一个 pem 文件中。使用 openssl 将 pem 转换为 pkcs12 文件格式。使用 pkcs12 文件和创建 pkcs12 期间使用的密码在代码中创建密钥库和信任库。 创建pkcs12文件的命令

    cat exampleserver.key > test.pem
    cat example.com.pem >> test.pem
    
    openssl pkcs12 -export -in test.pem -out test.pkcs12
    

    【讨论】:

      猜你喜欢
      • 2020-03-28
      • 1970-01-01
      • 2021-02-06
      • 2018-09-19
      • 2017-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多