【问题标题】:Get the public key from an HTTP server in Android从 Android 中的 HTTP 服务器获取公钥
【发布时间】:2021-01-13 09:16:58
【问题描述】:

我想在我的 Android 应用中从 HTTPS 服务器获取 RSA 公钥。

我不在乎它是否有效。

理想情况下;我希望能够提取有关整个证书链的信息。

如何做到这一点?

【问题讨论】:

    标签: android ssl https


    【解决方案1】:

    其实很简单。

    val url = URL(BASE_WEB_ENDPOINT_PRIMARY)
    val connection: HttpsURLConnection = url.openConnection() as HttpsURLConnection
    connection.connect()
    connection.serverCertificates.forEach {
      it.publicKey // <== the public key
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      • 2016-02-08
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多