gpt4 book ai didi

https - 如何为独立的 Wiremock 启用 HTTPS

转载 作者:行者123 更新时间:2023-12-04 21:35:15 27 4
gpt4 key购买 nike

概览:

我使用了 wiremock Standalone 2.1.11 并执行了以下操作来为我的请求启用 HTTPS URL,但无济于事:

  • 正在学习文档 http://wiremock.org/docs/running-standalone/
  • 添加 --https-port 但什么也没发生
  • 添加 keystore 但再次没有进展

  • 运行wiremock的命令如下:
    java -jar wiremock-standalone-2.1.11.jar --port 8920 --https-port 8921 --https-keystore /home/wiremock/keystore/clientkeystore --verbose

    注:
    我可以通过 http 端口正确连接

    现在,如果有人能帮我找到 HTTPS 连接的解决方案,我将不胜感激。

    最佳答案

  • 为wiremock生成java keystore
     keytool -genkey -alias wiremock -keyalg RSA -keysize 1024 \
    -validity 365 -keypass password -keystore identity.jks -storepass password

    重要 --- 按照提示指定证书详细信息:
  • 名字和姓氏:这不是您的名字,而是通用名称 (CN),例如“confluence.example.com”。 CN 必须与运行 Confluence 的服务器的完全限定主机名匹配,否则 Tomcat 将无法使用 SSL 证书。
  • 组织单位:这是申请证书的团队或部门,例如“营销”。
  • 组织:这是您的公司名称,例如“SeeSpaceEZ”。
    城市、州/省、国家/地区代码:这是您所在的位置,例如悉尼、新南威尔士州、澳大利亚。
  • 创建自签名证书
    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -config localhost.conf
  • 将证书导入 keystore
     keytool -import -trustcacerts -alias mock -file localhost.crt -keystore identity.jks
  • 在启用新 keystore 和 HTTPS 的情况下启动 wiremock
     java -jar wiremock-1.54-standalone.jar --https-port 8443 --https-keystore 
    ./identity.jks

  • 资源:

    答案来自
    https://gist.github.com/mobmad/433ba54e9cb97d6d7771#1-generate-self-signed-certificate

    关于https - 如何为独立的 Wiremock 启用 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39850326/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com