問題描述
Flutter 視頻播放器不接受自簽名 https 連接 (Flutter video player wont accept self signed https connection)
我正在開發一個 Flutter 應用程序,該應用程序連接到使用自簽名 HTTPS 的雲中的資產。
在 Flutter 應用程序中,我使用的是來自以下庫的 Chewie 和 VideoPlayerController:
p>import 'package:video_player/video_player.dart';
import 'package:chewie/chewie.dart';
視頻播放在遇到使用自簽名 SSL 證書的 HTTPS 資產時崩潰。我沒有看到任何忽略這個“問題”的選項。
這個錯誤有點籠統,但是當我切換回 HTTP 時,它工作得很好。這是我在使用自簽名 HTTPS 鏈接時從播放器收到的錯誤。
PlatformException: Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error
應該有某種方法可以使用自簽名 SSL,但我該怎麼做呢?
參考解法
方法 1:
Enable CleartextTraffic in Android manifest
// android:usesCleartextTraffic="true"
<application
android:label="App Name"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:icon="@mipmap/launcher_icon">
方法 2:
Hi dan The VideoPlayer widget should support self signed SSL. There's plenty of use cases for not having a CA signed certificate.
I also have the same issue, resolved it by getting the proper CA Certificate and doing some Network security configuration in android folder, please check below link for Network security configuration https://developer.android.com/training/articles/security‑config#CustomTrust
(by Dan、Bholendra Singh、Selim Abdel Monsef)