Skip to content

feat: iOS TLS fix — defer startTLS until didConnectToHost #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ios/TcpSocketClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ @interface TcpSocketClient () {
long _sendTag;
SecTrustRef _peerTrust;
SecIdentityRef _clientIdentity;
NSDictionary *_tlsOptionsPending;
}

- (id)initWithClientId:(NSNumber *)clientID
Expand Down Expand Up @@ -163,7 +164,7 @@ - (BOOL)connect:(NSString *)host
error:error];
}
if (result && tlsOptions) {
[self startTLS:tlsOptions];
_tlsOptionsPending = [tlsOptions copy]; // Save for later
}
return result;
}
Expand Down Expand Up @@ -573,7 +574,12 @@ - (void)socket:(GCDAsyncSocket *)sock

// Show up if SSL handsake is done
if (!_tls) {
[_clientDelegate onConnect:self];
if (_tlsOptionsPending) {
[self startTLS:_tlsOptionsPending];
_tlsOptionsPending = nil;
} else {
[_clientDelegate onConnect:self];
}
}
[sock readDataWithTimeout:-1 tag:_id.longValue];
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "react-native-tcp-socket",
"name": "@iostls/react-native-tcp-socket",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest, I don't know why you changed the package name and published a new one.

if you need this urgently, you should just use patch-package or yarn patch to apply the fix in your project.

"title": "React Native Tcp Socket",
"version": "6.3.0",
"description": "React Native TCP socket API for Android & iOS with SSL/TLS support",
"version": "6.3.0-iostls.0",
"description": "React Native TCP socket API for Android & iOS with SSL/TLS support.TLS-fixed fork of react-native-tcp-socket with iOS mutual auth support",
"main": "src/index.js",
"types": "lib/types/index.d.ts",
"scripts": {
Expand All @@ -26,7 +26,7 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/Rapsssito/react-native-tcp-socket.git",
"url": "https://github.com/manoaxcend/react-native-tcp-socket",
"baseUrl": "https://github.com/Rapsssito/react-native-tcp-socket"
},
"keywords": [
Expand Down