我正在使用此代码段对受 https 和 htpasswd 保护的服务器进行身份验证:
Authenticator.setDefault(object : Authenticator() {
override fun getPasswordAuthentication(): PasswordAuthentication {
return PasswordAuthentication("usernameinplaintext", "passwordinplaintext".toCharArray())
}
})
var sentBytes: Long = 0
HttpsURLConnection.setDefaultHostnameVerifier(NullHostNameVerifier())
val context = SSLContext.getInstance("TLS")
context.init(null, arrayOf<X509TrustManager>(NullX509TrustManager()), SecureRandom())
HttpsURLConnection.setDefaultSSLSocketFactory(context.socketFactory)
用户名和密码会以纯文本形式通过 Internet 发送吗?