Created
February 25, 2026 16:09
-
-
Save henry2man/1d621855de64e727bbca3244afb5cfc5 to your computer and use it in GitHub Desktop.
Sectigo HttpOverrides for Flutter: Custom `HttpOverrides` implementation to trust Sectigo root certificates on Android devices that don't include them in their system trust store. This solves SSL handshake errors for servers using Sectigo-issued certificates on older Android versions. Based on the `lehttp_overrides` package pattern but adapted f…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example usage | |
| void main() { | |
| // Fix for older android devices: Sectigo root certificate not in system trust store, | |
| // causing CERTIFICATE_VERIFY_FAILED on valid certificates for cateringhgonzalez.com | |
| if (Platform.isAndroid) { | |
| HttpOverrides.global = SectigoHttpOverrides(); | |
| } | |
| return runApp(const MyApp()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| import 'dart:io'; | |
| // Sectigo Public Server Authentication Root R46 | |
| const String kSectigoRootR46 = '''-----BEGIN CERTIFICATE----- | |
| MIIFijCCA3KgAwIBAgIQdY39i658BwD6qSWn4cetFDANBgkqhkiG9w0BAQwFADBf | |
| MQswCQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQD | |
| Ey1TZWN0aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBSNDYw | |
| HhcNMjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1OTU5WjBfMQswCQYDVQQGEwJHQjEY | |
| MBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1Ymxp | |
| YyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBSNDYwggIiMA0GCSqGSIb3DQEB | |
| AQUAA4ICDwAwggIKAoICAQCTvtU2UnXYASOgHEdCS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xOF3yEvJ+M0ejf5lG5Nkc/kLnHvALcWxxPDkjB | |
| JYOcCj+esQMzEhonrPcibCTRAUH4WAP+JWgiH5paPHxsnnVI84HxZmduTILA7rpX | |
| DhjvLpr3Etiga+kFpaHpaPi8TD8SHkXoUsCjvxInebnMMTzD9joiFgOgyY9mpFui | |
| TdaBJQbpdqQACj7LzTWb4OE4y2BThihCQRxEV+ioratF4yUQvNs+ZUH7G6aXD+u5 | |
| dHn5HrwdVw1Hr8Mvn4dGp+smWg9WY7ViYG4A++MnESLn/pmPNPW56MORcr3Ywx65 | |
| LvKRRFHQV80MNNVIIb/bE/FmJUNS0nAiNs2fxBx1IK1jcmMGDw4nztJqDby1ORrp | |
| 0XZ60Vzk50lJLVU3aPAaOpg+VBeHVOmmJ1CJeyAvP/+/oYtKR5j/K3tJPsMpRmAY | |
| QqszKbrAKbkTidOIijlBO8n9pu0f9GBj39ItVQGL | |
| -----END CERTIFICATE-----'''; | |
| class SectigoHttpOverrides extends HttpOverrides { | |
| static bool? _initRootCert; | |
| static bool _addRootCert() { | |
| if (Platform.isAndroid) { | |
| // Combine root and intermediate certificates | |
| // const String combinedCert = '$kSectigoRootR46\n$kSectigoIntermediateR36'; | |
| final List<int> rootCert = ascii.encode(kSectigoRootR46); | |
| SecurityContext.defaultContext.setTrustedCertificatesBytes(rootCert); | |
| } | |
| return true; | |
| } | |
| SectigoHttpOverrides() { | |
| _initRootCert ??= _addRootCert(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment