
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
react-native-ssl-manager
Advanced tools
React Native SSL Pinning provides seamless SSL certificate pinning integration for enhanced network security in React Native apps. This module enables developers to easily implement and manage certificate pinning, protecting applications against man-in-th
Production-ready SSL certificate pinning for React Native and Expo apps. This library provides seamless SSL certificate pinning integration for enhanced network security, protecting applications against man-in-the-middle (MITM) attacks. With dynamic configuration options and the ability to toggle SSL pinning, it's perfect for both development and production environments.
π± Interactive Features Shown:
- Toggle SSL pinning on/off
- Real-time API testing with visual feedback
- Certificate validation results
- Performance metrics display
π¬ Watch Full Demo Videos:
# Using npm
npm install react-native-ssl-manager
# Using yarn
yarn add react-native-ssl-manager
# Using bun
bun add react-native-ssl-manager
For iOS, run pod install:
cd ios && pod install
# Using expo CLI
npx expo install react-native-ssl-manager
# Using bun with expo
bunx expo install react-native-ssl-manager
Add the plugin to your app.json
or app.config.js
:
{
"expo": {
"plugins": [
[
"react-native-ssl-manager",
{
"sslConfigPath": "./ssl_config.json"
}
]
]
}
}
This library supports both React Native architectures:
The library automatically detects and uses the appropriate architecture at runtime.
Create a ssl_config.json
file in your project root:
{
"sha256Keys": {
"api.example.com": [
"sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"sha256/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB="
],
"api.dev.example.com": [
"sha256/CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC=",
"sha256/DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD="
]
}
}
import { setUseSSLPinning, getUseSSLPinning } from 'react-native-ssl-manager';
// Enable SSL pinning
await setUseSSLPinning(true);
// Check if SSL pinning is enabled
const isEnabled = await getUseSSLPinning();
console.log('SSL Pinning enabled:', isEnabled);
// Disable SSL pinning (for development/testing)
await setUseSSLPinning(false);
// Test with SSL pinning enabled
await setUseSSLPinning(true);
try {
const response = await fetch('https://api.example.com/data');
console.log('β
SSL Pinning working - request succeeded');
} catch (error) {
console.log('β οΈ Check your SSL configuration');
}
// Test without SSL pinning
await setUseSSLPinning(false);
const response = await fetch('https://api.example.com/data');
console.log('π Request without SSL pinning');
Create a configuration file with your domain certificates. Example structure:
{
"domains": {
"development": "api.dev.example.com",
"production": "api.example.com"
},
"sha256Keys": {
"api.dev.example.com": [
"sha256/certificate-hash-1=",
"sha256/certificate-hash-2="
],
"api.example.com": [
"sha256/certificate-hash-3=",
"sha256/certificate-hash-4="
]
}
}
setUseSSLPinning(usePinning: boolean): Promise<void>
Enables or disables SSL pinning dynamically.
// Enable SSL pinning
await setUseSSLPinning(true);
// Disable SSL pinning
await setUseSSLPinning(false);
Parameters:
usePinning
(boolean): Whether to enable SSL pinningReturns: Promise
getUseSSLPinning(): Promise<boolean>
Retrieves the current state of SSL pinning.
const isEnabled = await getUseSSLPinning();
console.log('SSL Pinning enabled:', isEnabled);
Returns: Promise - Current SSL pinning status
β οΈ Important: The configuration file must be named exactly ssl_config.json
and placed in your project root directory.
Your ssl_config.json
should follow this structure:
{
"sha256Keys": {
"your-api-domain.com": [
"sha256/primary-certificate-hash=",
"sha256/backup-certificate-hash="
],
"another-domain.com": [
"sha256/another-certificate-hash="
]
}
}
π File Location Requirements:
ssl_config.json
in project rootssl_config.json
in project root (same level as app.json
)ssl_config.json
When using setUseSSLPinning
, a restart of the application is required for changes to take effect. This is because SSL pinning is implemented at the native level.
First, install react-native-restart:
# Using npm
npm install react-native-restart
# Using yarn
yarn add react-native-restart
For iOS, run pod install:
cd ios && pod install
Then use it in your code:
import RNRestart from 'react-native-restart';
const toggleSSLPinning = async (enabled: boolean) => {
await setUseSSLPinning(enabled);
// Restart the app to apply changes
RNRestart.Restart();
};
// Example with user confirmation
const handleSSLToggle = async (enabled: boolean) => {
// Save any necessary state
await saveAppState();
// Update SSL pinning
await setUseSSLPinning(enabled);
// Show user message
Alert.alert(
'Restart Required',
'The app needs to restart to apply security changes.',
[
{
text: 'Restart Now',
onPress: () => RNRestart.Restart()
}
]
);
};
Environment Management
Performance Optimization
Security Considerations
β Expo Plugin Integration - COMPLETED!
β New Architecture Support - COMPLETED!
β Production Optimizations - COMPLETED!
π Advanced Certificate Management
π Enhanced Developer Experience
π§ Extended Platform Support
This library comes with a comprehensive test app that demonstrates SSL pinning functionality:
# Clone the repository
git clone https://github.com/huytdps13400/react-native-ssl-manager.git
# Test with React Native CLI
cd react-native-ssl-manager/example
npm install
npm run ios # or npm run android
# Test with Expo
cd ../example-expo
npm install
npx expo run:ios # or npx expo run:android
The example app provides:
π Test without SSL Pinning:
await setUseSSLPinning(false);
// All API calls should work normally
π Test with SSL Pinning (Correct Certificate):
await setUseSSLPinning(true);
// Calls to pinned domains should work
const response = await fetch('https://your-pinned-domain.com/api');
β οΈ Test with SSL Pinning (Wrong Certificate):
await setUseSSLPinning(true);
// Calls to non-pinned domains should fail
try {
await fetch('https://unpinned-domain.com/api');
} catch (error) {
console.log('β
SSL Pinning working - blocked untrusted certificate');
}
Proxyman is a powerful tool for testing SSL pinning implementation. Here's how you can verify your SSL pinning configuration:
Install Proxyman
Testing SSL Pinning
// Enable SSL Pinning
await setUseSSLPinning(true);
// Make API requests through your app
// If SSL pinning is working correctly:
// - Requests will fail when Proxyman tries to intercept them
// - You'll see SSL/TLS handshake errors
// Disable SSL Pinning for debugging
await setUseSSLPinning(false);
// Now you can intercept and inspect API calls with Proxyman
Verify SSL Pinning is Active
Debug API Calls
Certificate Validation
This integration with Proxyman makes it easy to:
We welcome contributions! See the contributing guide to learn how to contribute to the repository and the development workflow.
# Clone the repository
git clone https://github.com/huytdps13400/react-native-ssl-manager.git
cd react-native-ssl-manager
# Install dependencies (choose your package manager)
npm install
# or
yarn install
# or
bun install
# Build the library
npm run build
# or
bun run build
# Run tests
npm test
# or
bun test
# Test with example apps
npm run example:ios
npm run example:android
npm run example-expo:ios
npm run example-expo:android
# Test Bun compatibility
bun run bun:test-compatibility
MIT License - see the LICENSE file for details.
Made with β€οΈ for the React Native community
FAQs
React Native SSL Pinning provides seamless SSL certificate pinning integration for enhanced network security in React Native apps. This module enables developers to easily implement and manage certificate pinning, protecting applications against man-in-th
The npm package react-native-ssl-manager receives a total of 87 weekly downloads. As such, react-native-ssl-manager popularity was classified as not popular.
We found that react-native-ssl-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.