Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke committed Feb 10, 2024
1 parent 2ab1256 commit dfa7c34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 4 additions & 2 deletions okhttp/src/main/kotlin/okhttp3/OkHttpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1052,11 +1052,13 @@ open class OkHttpClient internal constructor(
*/
fun certificatePinner(certificatePinner: CertificatePinner) =
apply {
if (certificatePinner != this.certificatePinner) {
val cleanCertificatePinner = CertificatePinner(certificatePinner.pins)

if (cleanCertificatePinner != this.certificatePinner) {
this.routeDatabase = null
}

this.certificatePinner = certificatePinner
this.certificatePinner = cleanCertificatePinner
}

/**
Expand Down
13 changes: 12 additions & 1 deletion okhttp/src/test/java/okhttp3/OkHttpClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ class OkHttpClientTest {
.routeDatabase,
)

// identical CertificatePinner
assertSame(
client.routeDatabase,
client.newBuilder()
.certificatePinner(CertificatePinner.Builder().build())
.build()
.routeDatabase,
)

// logically different scope of client for route db
assertNotSame(
client.routeDatabase,
Expand Down Expand Up @@ -422,7 +431,9 @@ class OkHttpClientTest {
assertNotSame(
client.routeDatabase,
client.newBuilder()
.certificatePinner(CertificatePinner.Builder().build())
.certificatePinner(CertificatePinner.Builder()
.add("san.com", "sha1/afwiKY3RxoMmLkuRW1l7QsPZTJPwDS2pdDROQjXw8ig=")
.build())
.build()
.routeDatabase,
)
Expand Down

0 comments on commit dfa7c34

Please sign in to comment.