首页 > 解决方案 > 使用 HostnameVerifier 接口(Kotlin)的不安全实现的 Android 应用

问题描述

该应用程序是在 Kotlin 中开发的,我使用 okHttpClient 进行 API 调用我试图将它托管在 Play 商店中,但它们给了我一个漏洞问题:

HostnameVerifier 
Your app(s) are using an unsafe implementation of the HostnameVerifier interface. You can find more information about how to resolve the issue in this Google Help Center article. 

我的代码:

    private val gson = GsonBuilder().setLenient().create()
private var httpLogger = HttpLoggingInterceptor()
        .setLevel(HttpLoggingInterceptor.Level.BODY)

private val customClient = OkHttpClient.Builder()
        .addInterceptor(httpLogger)
        .addInterceptor(ConnectivityInterceptor())
        .build()
private val sRetrofitBuilder = Retrofit.Builder()
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .client(customClient)
        .addConverterFactory(GsonConverterFactory.create(gson))
        .baseUrl(DataUtils.getString(R.string.api_base_url))
        .build()

该应用程序在调试版本中运行良好

标签: androidkotlinandroid-securityandroid-securityexception

解决方案


推荐阅读