【问题标题】:How to serve https requests in Ktor programmatically如何以编程方式在 Ktor 中提供 https 请求
【发布时间】:2020-03-07 02:28:15
【问题描述】:

要在 Ktor 中服务 https 请求,他们的文档指出您需要在 application.conf 中设置一些配置属性 (ktor.security.ssl),以便 Ktor 可以找到 ssl 证书。但是,我想从另一台服务器(通过加密连接)检索 ssl 证书。

我能否设置我的 Ktor 服务器,以便在服务器启动时检索此证书并启用 https?

【问题讨论】:

    标签: kotlin https ktor


    【解决方案1】:

    如果还有人对此感到疑惑,方法是将您的 Ktor 服务器作为嵌入式服务器启动,并为其提供您自己的 ApplicationEngineEnvironment(作为参考,您可以使用函数 io.ktor.server.engine.CommandLine.Kt)。

    在此ApplicationEngineEnvironment 中,您可以自定义加载 SSL 证书的方式。

    【讨论】:

      猜你喜欢
      • 2023-03-26
      • 2010-11-21
      • 2011-04-13
      • 2019-05-06
      • 1970-01-01
      • 2014-03-03
      • 2011-01-17
      • 2022-01-23
      • 1970-01-01
      相关资源
      最近更新 更多