Line data Source code
1 : // Copyright 2026 The terCAD team. All rights reserved.
2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.
3 :
4 : import 'dart:convert';
5 : import 'dart:io';
6 :
7 : import 'package:http/http.dart' as http;
8 : import 'package:http/io_client.dart';
9 :
10 : const bool isTellerCertificateSupported = true;
11 :
12 : // Mutual TLS: the certificate and the private key issued in the Teller Dashboard identify the application
13 0 : http.Client createTellerHttpClient({String? certificate, String? privateKey}) {
14 : if (certificate == null || privateKey == null) {
15 0 : return http.Client();
16 : }
17 0 : final context = SecurityContext(withTrustedRoots: true)
18 0 : ..useCertificateChainBytes(utf8.encode(certificate))
19 0 : ..usePrivateKeyBytes(utf8.encode(privateKey));
20 0 : return IOClient(HttpClient(context: context));
21 : }
|