https://kotlinlang.org logo
Title
r

Robert Munro

07/07/2022, 9:37 AM
Is there a way to do certificate pinning on the apollo-kotlin
ApolloClient
? (i.e. with out OkHttp for multi-platform)
m

mbonnin

07/07/2022, 9:39 AM
I don't think there's anything builtin. You'd have to do expect/actual and configure
NSUrlSession
/`OkHttp` separately
r

Robert Munro

07/07/2022, 9:44 AM
ok so for multiplatform i would have to implement the HttpEngine interface and use
NSUrlSession
/`OkHttp` individually i guess?
m

mbonnin

07/07/2022, 9:44 AM
Yep, that'd be the way to go
r

Robert Munro

07/07/2022, 9:45 AM
thanks 🙂
m

mbonnin

07/07/2022, 9:45 AM
Sure thing!
Ultimately, I think an answer to this question could be to provide a HttpEngine based on Ktor so that you can configure Ktor in a single place instead of having to configure OkHttp/NSUrlSession
(assuming Ktor supports certificate pinning but sounds like something it should support
r

Robert Munro

07/07/2022, 9:47 AM
yes that might be a better option actually then its KMP compatible if it needs to be reused for other platforms too
m

mbonnin

07/07/2022, 9:48 AM
might not be too hard to do given that we use Ktor for JS
r

Robert Munro

07/07/2022, 9:49 AM
do you think it would be possible/good to support at the
ApolloCilent.Builder
level?
as im just using the
DefaultHttpEngine
atm
m

mbonnin

07/07/2022, 9:59 AM
do you think it would be possible/good to support at the
ApolloCilent.Builder
level?
I think we'd need something like
ApolloClient.Builder().httpEngine(ktorEngine)
Where
KtorEngine
is an Apollo-provided wrapper around Ktor
r

Robert Munro

07/07/2022, 10:01 AM
yes true
m

mbonnin

07/07/2022, 10:01 AM
Maybe it's a matter of taking the JS HttpEngine and making it available on the other platforms
Maybe there's a bit more to it, not sure