Skip to content
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

Add SocketRocket Security Policy Provider #44396

Closed
wants to merge 2 commits into from
Closed

Add SocketRocket Security Policy Provider #44396

wants to merge 2 commits into from

Conversation

djorkaeffalexandre
Copy link

@djorkaeffalexandre djorkaeffalexandre commented May 2, 2024

Summary:

When you have a server that is under a Client Certificate logic, and has some connection to it using websockets, you can't provide the security policy to the instance created for the socket on RCTWebSocketModule.

Following what we have for RCTNetworking where you can inject a custom configuration for the URLSession created, these changes aim to implement a similar way to provide a custom handler for creating a Socket Rocket SecurityPolicy based on the request that will be sent through the socket.

SRSecurityPolicyProvider providerBlock = ^SRSecurityPolicy *(NSURLRequest *request) {
  if (request.URL == @"myclientcertificate.domain.com") {
    return ...;
  };
  return NULL;
}
  
RCTSetSRSecurityPolicyProvider(providerBlock);

Changelog:

[IOS] [CHANGED] - Add SocketRocket Security Policy Provider

Test Plan:

I can't provide my own server with the client certificate here, but the important piece of code is above, this is a customization that is important to react-native developers, for Android we already have a way to customize the OkHttp instance being used by the socket, that I proposed some time ago, so this new api will make it easier for developers to inject custom websocket security policies for iOS too, since they will not need to do any method swizzling or fork of react-native.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants