Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class OkHttpTest {
assertTrue(tlsVersion == TlsVersion.TLS_1_2 || tlsVersion == TlsVersion.TLS_1_3)
assertEquals(
"CN=localhost",
(response.handshake!!.peerCertificates.first() as X509Certificate).subjectDN.name,
(response.handshake!!.peerCertificates.first() as X509Certificate).subjectX500Principal.name,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class HandshakeCertificatesTest {
val acceptedIssuers = handshakeCertificates.trustManager.acceptedIssuers
val names =
acceptedIssuers
.map { it.subjectDN.name }
.map { it.subjectX500Principal.name }
.toSet()

// It's safe to assume all platforms will have a major Internet certificate issuer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class CertificatePinner internal constructor(
append("\n ")
append(pin(element))
append(": ")
append(element.subjectDN.name)
append(element.subjectX500Principal.name)
}
append("\n Pinned certificates for ")
append(hostname)
Expand Down
2 changes: 1 addition & 1 deletion okhttp/src/commonJvmAndroid/kotlin/okhttp3/Handshake.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Handshake internal constructor(
private val Certificate.name: String
get() =
when (this) {
is X509Certificate -> subjectDN.toString()
is X509Certificate -> subjectX500Principal.toString()
else -> type
}

Expand Down
1 change: 1 addition & 0 deletions okhttp/src/commonJvmAndroid/kotlin/okhttp3/HttpUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class HttpUrl private constructor(
get() = scheme == "https"

/** Returns this URL as a [java.net.URL][URL]. */
@Suppress("deprecation")
@JvmName("url")
fun toUrl(): URL {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class ConnectPlan internal constructor(
"""
|Hostname ${address.url.host} not verified:
| certificate: ${CertificatePinner.pin(cert)}
| DN: ${cert.subjectDN.name}
| DN: ${cert.subjectX500Principal.name}
| subjectAltNames: ${OkHostnameVerifier.allSubjectAltNames(cert)}
""".trimMargin(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class BasicCertificateChainCleaner(
signingCert: X509Certificate,
minIntermediates: Int,
): Boolean {
if (toVerify.issuerDN != signingCert.subjectDN) {
if (toVerify.issuerX500Principal != signingCert.subjectX500Principal) {
return false
}
if (signingCert.basicConstraints < minIntermediates) {
Expand Down
2 changes: 1 addition & 1 deletion okhttp/src/jvmTest/kotlin/okhttp3/CallKotlinTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CallKotlinTest {
assertEquals(200, response.code)
assertEquals(
"CN=localhost",
(response.handshake!!.peerCertificates.single() as X509Certificate).subjectDN.name,
(response.handshake!!.peerCertificates.single() as X509Certificate).subjectX500Principal.name,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion okhttp/src/jvmTest/kotlin/okhttp3/URLConnectionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4509,7 +4509,7 @@ class URLConnectionTest {
private fun certificatesToString(certificates: Array<X509Certificate>): String {
val result: MutableList<String> = ArrayList()
for (certificate in certificates) {
result.add(certificate.subjectDN.toString() + " " + certificate.serialNumber)
result.add(certificate.subjectX500Principal.toString() + " " + certificate.serialNumber)
}
return result.toString()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class CustomTrust {
println(response.body.string())

for (peerCertificate in response.handshake?.peerCertificates.orEmpty()) {
println((peerCertificate as X509Certificate).subjectDN)
println((peerCertificate as X509Certificate).subjectX500Principal)
}
}
}
Expand Down
Loading