Skip to content

Commit 0cae69b

Browse files
committed
first draft
1 parent f71f6d8 commit 0cae69b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

at_lookup/lib/at_lookup.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export 'src/exception/at_lookup_exception.dart';
1111
export 'src/monitor_client.dart';
1212
export 'src/cache/secondary_address_finder.dart';
1313
export 'src/cache/cacheable_secondary_address_finder.dart';
14+
export 'src/util/secure_socket_util.dart';

at_lookup/lib/src/at_lookup_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@ class AtLookupImpl implements AtLookUp {
470470
!(_isPkamAuthenticated || _isCramAuthenticated);
471471
}
472472

473-
Future<bool> createOutBoundConnection(host, port, toAtSign) async {
473+
Future<bool> createOutBoundConnection(host, port, toAtSign, {decryptPackets = false}) async {
474474
try {
475-
var secureSocket = await SecureSocket.connect(host, int.parse(port));
475+
var secureSocket = await SecureSocketUtil.createSecureContext(host, port, decryptPackets: decryptPackets);
476476
_connection = OutboundConnectionImpl(secureSocket);
477477
if (outboundConnectionTimeout != null) {
478478
_connection!.setIdleTime(outboundConnectionTimeout);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'dart:io';
2+
class SecureSocketUtil{
3+
///method that creates and returns a [SecureSocket]. If [decryptPackets] is set to true,the TLS keys are logged into a file.
4+
static Future<SecureSocket> createSecureContext(host, port, {decryptPackets = false}){
5+
if (decryptPackets){
6+
SecurityContext securityContext = SecurityContext();
7+
File keysFile = File('tls_keys_file');
8+
//securityContext.setTrustedCertificates();
9+
return SecureSocket.connect(host, int.parse(port), context: securityContext, keyLog: (line) => keysFile.writeAsStringSync(line, mode: FileMode.append));
10+
}
11+
else{
12+
return SecureSocket.connect(host, int.parse(port));
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)