Comments (4)
- We no longer provide support to
dio: <5.0.0
. - Do some search: https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/troubleshooting/#connect-to-app-services-using-android-7-or-older
from dio.
- We no longer provide support to .
dio: <5.0.0
- Do some search: https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/troubleshooting/#connect-to-app-services-using-android-7-or-older
dio: ^5.0.0 was also tested and the problem remains! I have doubts that the signature algorithm for the certificate format does not support IP certificates, and the support is not perfect! But there is no documentation
According to the example, the following error is displayed:
DioException [unknown]: null
Error: HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: Hostname mismatch(../../third_party/boringssl/src/ssl/handshake.cc:393))
from dio.
Previously, the IP certificate was deployed on the HTTP server, now replace the certificate with the domain name certificate! Create a new test code in the test directory.
dio.httpClientAdapter = IOHttpClientAdapter(
createHttpClient: () {
SecurityContext securityContext =
SecurityContext(withTrustedRoots: true);
**securityContext.setTrustedCertificates('assets/ca-cert.crt'); or
securityContext.useCertificateChainBytes(File('assets/ca-cert.crt').readAsBytesSync());**
final client = HttpClient(
context: securityContext,
);
client.badCertificateCallback = (cert, host, port) => true;
return client;
},
);
This code will work in a separate test file with setTrustedCertificates and useCertificateChainBytes Settings. But placing the code in the project indicates that the certificate file is not found
I/flutter ( 6689): Error: FileSystemException: Cannot open file, path = 'assets/ca-cert.crt' (OS Error: No such file or directory, errno = 2)
from dio.
-
Dio (HttpClient) certificate authentication The support for IP certificate authentication is not perfect.
-
Using File('assets/ca.crt').readAsBytesSync() or await rootBundle.load("assets/ca.crt") in the Widget neither of these methods work properly
FileSystemException: Cannot open file
. But it works fine until the main function calls runApp(const App()), I don't know why! -
In the main () function configuration HttpOverrides. The method of HttpOverrides.global = _HttpOverrides _HttpOverrides. createHttpClient will be multiple calls even if I just call the HTTP request at a time, Setting the certificate is also invalid, and this method is only suitable for ignoring the certificate globally.
The solution:
Adds a global variable, initialized before runApp(const App()).Use this global variable where http requests are required
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
var chainBytes = await rootBundle.load("assets/ca.crt");
Global.dio.httpClientAdapter = IOHttpClientAdapter(
createHttpClient: () {
SecurityContext securityContext = SecurityContext(withTrustedRoots: true);
securityContext.setTrustedCertificatesBytes(chainBytes.buffer.asUint8List());
// securityContext.useCertificateChainBytes(chainBytes.buffer.asUint8List());
final client = HttpClient(
context: securityContext,
);
// client.badCertificateCallback = (cert, host, port) => true;
return client;
},
);
runApp(const BiliApp());
}
This may not be the best way but it's the one I can think of right now.
from dio.
Related Issues (20)
- [🔔 Dio] sendTimeout cannot be used without a request body to send HOT 2
- `Transformer.isJsonMimeType` throws format exceptions without caught
- onError is not returning any error HOT 3
- Error when uploading image using MultipartFile.fromBytes in version 5.4.3+1 HOT 1
- 为什么dio的fromMap会将MultipartFile自动放入files字段中 HOT 1
- Error: The method 'debugLog' isn't defined for the class 'BrowserHttpClientAdapter'. HOT 1
- Version 5.5.0 brakes the web build HOT 1
- Is it now possible to use DIO / dio_web_adapter with Web/WASM? HOT 41
- Dio 5.5 broke compilation for WASM HOT 6
- ResponseType.stream returns responce all at once on Web HOT 1
- Date header not parsed correctly HOT 1
- set proxy for BrowserHttpClientAdapter HOT 1
- Dio fetch can't catch error HOT 1
- Return the app to the desktop, then switch to Wi Fi in the system. After switching to Wi Fi, click on the desktop app icon to enter the app. At this point, there is an exception when sending network requests. This is highly likely to occur on Ios HOT 5
- when using "handler.reject(error);" in onError of interceptors, I cannot DioException in .catchError(), but find it in .then(). HOT 1
- Dio cannot connect to the Internet after VPN is enabled on iOS devices HOT 1
- Response has unsupport header throw exception: Failed to parse header value.message HOT 6
- Network calls gets stuck on iOS 16.6+ and 17 HOT 1
- Dio Throws Exception on DELETE Request with 204 Response HOT 4
- BrowserHttpClientAdapter() error in web. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dio.