Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
everyline opened this issue Dec 25, 2023 · 9 comments
Open

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

everyline opened this issue Dec 25, 2023 · 9 comments

Comments

@everyline
Copy link

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

@ssseasonnn
Copy link
Owner

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

@everyline
Copy link
Author

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

@everyline
Copy link
Author

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

@ssseasonnn
Copy link
Owner

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

@everyline
Copy link
Author

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

@ssseasonnn
Copy link
Owner

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

@ssseasonnn
Copy link
Owner

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
Copy link
Author

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

@everyline
Copy link
Author

ok 已经解决了 谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants