ssseasonnn / RxDownload

A multi-threaded download tool written with RxJava and Kotlin
Apache License 2.0
4.14k stars 612 forks source link

请问怎么修改 才能支持https 请求 #362

Open everyline opened 8 months ago

everyline commented 8 months ago

能否给出具体的代码 支持https 请求

ssseasonnn commented 8 months ago

正常情况下不需要任何修改就支持https,如果你的连接是自己签发的证书,那需要你自己配置okhttp让它信任你自己的证书

everyline commented 8 months ago

不是自己签发的证书 ,是默认所有的证书 会下载失败 不支持https

everyline commented 8 months ago

如果是配置okhttp 信任自己的证书 需要怎么写

ssseasonnn commented 8 months ago

你能把你具体的报错信息贴出来吗?你说不支持https,你有把demo代码拉下来看吗?demo里就是https的下载链接

everyline commented 8 months ago

图片 Hostname 39.165.164.20 not verified: certificate: sha256/MS2HqIvRWLHr0b6GGKPUzqB6xsUxE6t4SDhSH6I/jro= DN: CN=yc.hngfyjy.com subjectAltNames: [yc.hngfyjy.com]

ssseasonnn commented 8 months ago

https://blog.csdn.net/zzz_zzz_z/article/details/51824765, 这里有解决办法

ssseasonnn commented 8 months ago

fun Task.download( header: Map<String, String> = RANGE_CHECK_HEADER, maxConCurrency: Int = DEFAULT_MAX_CONCURRENCY, rangeSize: Long = DEFAULT_RANGE_SIZE, dispatcher: Dispatcher = DefaultDispatcher, validator: Validator = SimpleValidator, storage: Storage = SimpleStorage, request: Request = RequestImpl, // 替换你自己的Request对象 watcher: Watcher = WatcherImpl )

创建任务的时候,指定你自己的Request对象,在你自己的Request对象里面,添加okhttp信任所有证书的代码

everyline commented 8 months ago

https://39.165.164.20:8888/lingzhang_1.0_release.apk 就是这样的https 请求

everyline commented 8 months ago

ok 已经解决了 谢谢