-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: test server tls, local-did-web-resolver inject http client (#4)
- Loading branch information
1 parent
80a6feb
commit 5c24861
Showing
7 changed files
with
71 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import id.walt.did.dids.resolver.local.DidWebResolver | ||
import io.ktor.client.* | ||
import io.ktor.client.engine.cio.* | ||
import io.ktor.client.plugins.contentnegotiation.* | ||
import io.ktor.network.tls.* | ||
import io.ktor.serialization.kotlinx.json.* | ||
import java.security.cert.X509Certificate | ||
import javax.net.ssl.X509TrustManager | ||
|
||
object TestClient { | ||
|
||
val http = HttpClient(CIO) { | ||
install(ContentNegotiation) { | ||
json(DidWebResolver.json) | ||
} | ||
engine { | ||
https { | ||
trustManager = TrustAllManager(this) | ||
} | ||
} | ||
} | ||
|
||
private class TrustAllManager(config: TLSConfigBuilder) : X509TrustManager { | ||
private val delegate = config.build().trustManager | ||
override fun checkClientTrusted(certificates: Array<out X509Certificate>?, authType: String?) {} | ||
override fun checkServerTrusted(certificates: Array<out X509Certificate>?, authType: String?) {} | ||
override fun getAcceptedIssuers(): Array<X509Certificate> = delegate.acceptedIssuers | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.