diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 3260c8e..b5bf8f3 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -15,7 +15,7 @@ jobs: with: node-version: 10.0.0 - name: Publish if version has been updated - uses: pascalgn/npm-publish-action@1.3.4 + uses: pascalgn/npm-publish-action@1.3.9 with: # All of theses inputs are optional tag_name: "v%s" tag_message: "v%s" @@ -26,3 +26,4 @@ jobs: env: # More info about the environment variables in the README GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings + \ No newline at end of file diff --git a/ios/RNSslPinning.podspec b/RNSslPinning.podspec similarity index 74% rename from ios/RNSslPinning.podspec rename to RNSslPinning.podspec index 4df35d2..538e9b1 100644 --- a/ios/RNSslPinning.podspec +++ b/RNSslPinning.podspec @@ -1,6 +1,6 @@ require 'json' -package = JSON.parse(File.read(File.join(__dir__, '../package.json'))) +package = JSON.parse(File.read(File.join(__dir__, './package.json'))) Pod::Spec.new do |s| s.name = "RNSslPinning" @@ -10,10 +10,10 @@ Pod::Spec.new do |s| s.homepage = package['homepage'] s.license = package['license'] # s.license = { :type => "MIT", :file => "FILE_LICENSE" } - s.author = { "author" => "author@domain.cn" } + s.author = { "author" => "author@domain.cn" } s.platform = :ios, "9.0" s.source = { :git => "https://github.com/MaxToyberman/react-native-ssl-pinning", :tag => "master" } - s.source_files = "RNSslPinning/**/*.{h,m}" + s.source_files = "ios/RNSslPinning/**/*.{h,m}" s.requires_arc = true @@ -21,5 +21,3 @@ Pod::Spec.new do |s| s.dependency "AFNetworking", "~> 4.0" end - - \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 8e32614..efb23b8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -32,10 +32,10 @@ repositories { dependencies { implementation "com.facebook.react:react-native:+" - implementation "com.squareup.okhttp3:okhttp:4.2.2" + implementation "com.squareup.okhttp3:okhttp:4.9.0" implementation "com.squareup.okio:okio:2.6.0" implementation "com.github.franmontiel:PersistentCookieJar:v1.0.1" - implementation "com.squareup.okhttp3:logging-interceptor:4.2.2" - implementation "com.squareup.okhttp3:okhttp-urlconnection:4.2.2" + implementation "com.squareup.okhttp3:logging-interceptor:4.9.0" + implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.0" } diff --git a/ios/RNSslPinning/RNSslPinning.m b/ios/RNSslPinning/RNSslPinning.m index 3179a72..bb6dfe5 100644 --- a/ios/RNSslPinning/RNSslPinning.m +++ b/ios/RNSslPinning/RNSslPinning.m @@ -215,6 +215,7 @@ -(void) performMultipartRequest: (AFURLSessionManager*)manager obj:(NSDictionary AFSecurityPolicy *policy; BOOL pkPinning = [[obj objectForKey:@"pkPinning"] boolValue]; BOOL disableAllSecurity = [[obj objectForKey:@"disableAllSecurity"] boolValue]; + NSString *certBase64=[obj objectForKey:@"cert"]; NSSet *certificates = [AFSecurityPolicy certificatesInBundle:[NSBundle mainBundle]]; @@ -227,6 +228,14 @@ -(void) performMultipartRequest: (AFURLSessionManager*)manager obj:(NSDictionary else if (pkPinning){ policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey withPinnedCertificates:certificates]; } + else if (certBase64) { + NSURL *certData = [NSURL URLWithString: [NSString stringWithFormat:@"data:application/octet-stream;base64,%@", certBase64]]; + NSData *certRaw = [NSData dataWithContentsOfURL:certData]; + policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate + withPinnedCertificates:[NSSet setWithObject:certRaw]]; + policy.validatesDomainName = false; + policy.allowInvalidCertificates = true; + } else{ policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate withPinnedCertificates:certificates]; } diff --git a/package.json b/package.json index b645475..78b7e7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-ssl-pinning", - "version": "1.5.4", + "version": "1.5.7", "description": "React-Native Ssl pinning using OkHttp 3 in Android, and AFNetworking on iOS.", "main": "index.js", "scripts": { @@ -17,7 +17,7 @@ "license": "MIT", "homepage": "https://github.com/MaxToyberman/react-native-ssl-pinning#README", "peerDependencies": { - "react-native": "^0.41.2" + "react-native": "*" }, "repository": { "type": "git",