Skip to content
Merged
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
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
DEVELOPER_DIR: /Applications/Xcode_26.6.app/Contents/Developer

jobs:
test:
name: Test ${{ matrix.platform }}
runs-on: macos-26
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
platform: [ios-simulator, macos, tvos-simulator]
steps:
- uses: actions/checkout@v7
- run: ./scripts/run_unit_tests.sh ${{ matrix.platform }} -retry-tests-on-failure -test-iterations 3
- uses: actions/upload-artifact@v7
if: failure()
with:
name: ${{ matrix.platform }}-tests
path: output/*.xcresult
if-no-files-found: ignore

xcframework:
name: Build XCFramework
runs-on: macos-26
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- run: ./scripts/build_xcframework.sh

swift-package:
name: Validate Swift package
runs-on: macos-26
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- run: ./scripts/validate_swift_package.sh
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release

on:
release:
types: [published]

permissions:
contents: write

env:
DEVELOPER_DIR: /Applications/Xcode_26.6.app/Contents/Developer

jobs:
xcframework:
name: Attach XCFramework
runs-on: macos-26
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- run: ./scripts/build_xcframework.sh
- run: gh release upload "$GITHUB_REF_NAME" output/TrustKit-static.zip --clobber
env:
GH_TOKEN: ${{ github.token }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ _site
.swiftpm/

.DS_Store

# CI
output/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TrustKit
========

[![Build Status](https://app.bitrise.io/app/fe29405fb90f94ea/status.svg?token=TJ3o4dhSWa--0ZlJT7FV1A)](https://app.bitrise.io/app/fe29405fb90f94ea) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Version Status](https://img.shields.io/cocoapods/v/TrustKit.svg?style=flat)](https://cocoapods.org/pods/TrustKit) [![Platform](https://img.shields.io/cocoapods/p/TrustKit.svg?style=flat)](https://cocoapods.org/pods/TrustKit) [![License MIT](https://img.shields.io/cocoapods/l/TrustKit.svg?style=flat)](https://en.wikipedia.org/wiki/MIT_License)
[![Build Status](https://github.com/datatheorem/TrustKit/actions/workflows/ci.yml/badge.svg)](https://github.com/datatheorem/TrustKit/actions/workflows/ci.yml) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Version Status](https://img.shields.io/cocoapods/v/TrustKit.svg?style=flat)](https://cocoapods.org/pods/TrustKit) [![Platform](https://img.shields.io/cocoapods/p/TrustKit.svg?style=flat)](https://cocoapods.org/pods/TrustKit) [![License MIT](https://img.shields.io/cocoapods/l/TrustKit.svg?style=flat)](https://en.wikipedia.org/wiki/MIT_License)
[![Gitter chat](https://badges.gitter.im/datatheorem/gitter.png)](https://gitter.im/TrustKit/Lobby)

**TrustKit** is an open source framework that makes it easy to deploy SSL public key pinning and reporting in any iOS 12+, macOS 10.13+, tvOS 12+ or watchOS 4+ App; it supports both Swift and Objective-C Apps.
Expand Down
2 changes: 1 addition & 1 deletion TrustKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "TrustKit"
s.version = "3.0.7"
s.version = "3.0.8"
s.summary = 'TrustKit is an open source framework that makes it easy to deploy SSL pinning in any iOS, macOS, tvOS or watchOS App.'
s.homepage = "https://datatheorem.github.io/TrustKit"
s.documentation_url = 'https://datatheorem.github.io/TrustKit/documentation/'
Expand Down
2 changes: 2 additions & 0 deletions TrustKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,7 @@
HEADER_SEARCH_PATHS = "$(SRCROOT)/**";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 3.0.8;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -1655,6 +1656,7 @@
HEADER_SEARCH_PATHS = "$(SRCROOT)/**";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 3.0.8;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx";
Expand Down
2 changes: 1 addition & 1 deletion TrustKit/Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion TrustKit/TSKTrustKitConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#import "TSKTrustKitConfig.h"

NSString * const TrustKitVersion = @"3.0.0";
NSString * const TrustKitVersion = @"3.0.8";

// General keys
const TSKGlobalConfigurationKey kTSKSwizzleNetworkDelegates = @"TSKSwizzleNetworkDelegates";
Expand Down
4 changes: 4 additions & 0 deletions TrustKit/public/TSKPinningValidator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

*/

#if __has_include(<TrustKit/TSKTrustDecision.h>)
#import <TrustKit/TSKTrustDecision.h>
#else
#import "TSKTrustDecision.h"
#endif
#import <Foundation/Foundation.h>

@class TSKPinningValidatorResult;
Expand Down
5 changes: 5 additions & 0 deletions TrustKit/public/TSKPinningValidatorCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
#ifndef TSKPinningValidatorCallback_h
#define TSKPinningValidatorCallback_h

#if __has_include(<TrustKit/TSKPinningValidatorResult.h>)
#import <TrustKit/TSKPinningValidatorResult.h>
#import <TrustKit/TSKTrustKitConfig.h>
#else
#import "TSKPinningValidatorResult.h"
#import "TSKTrustKitConfig.h"
#endif

/**
The pinning policy set for a specific hostname.
Expand Down
4 changes: 4 additions & 0 deletions TrustKit/public/TSKPinningValidatorResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

*/

#if __has_include(<TrustKit/TSKTrustDecision.h>)
#import <TrustKit/TSKTrustDecision.h>
#else
#import "TSKTrustDecision.h"
#endif
#import <Foundation/Foundation.h>

/**
Expand Down
8 changes: 8 additions & 0 deletions TrustKit/public/TrustKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@

#ifndef _TRUSTKIT_
#define _TRUSTKIT_
#if __has_include(<TrustKit/TSKTrustKitConfig.h>)
#import <TrustKit/TSKTrustKitConfig.h>
#import <TrustKit/TSKPinningValidatorResult.h>
#import <TrustKit/TSKPinningValidatorCallback.h>
#import <TrustKit/TSKPinningValidator.h>
#import <TrustKit/TSKTrustDecision.h>
#else
#import "TSKTrustKitConfig.h"
#import "TSKPinningValidatorResult.h"
#import "TSKPinningValidatorCallback.h"
#import "TSKPinningValidator.h"
#import "TSKTrustDecision.h"
#endif
#endif /* _TRUSTKIT_ */

NS_ASSUME_NONNULL_BEGIN
Expand Down
8 changes: 4 additions & 4 deletions TrustKitTests/TSKEndToEndNSURLSessionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ - (void)testPinningValidationFailed
[task resume];

// Wait for the connection to succeed and ensure a notification was posted
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error)
[self waitForExpectationsWithTimeout:30.0 handler:^(NSError *error)
{
if (error)
{
Expand Down Expand Up @@ -231,7 +231,7 @@ - (void)testPinningValidationSucceeded
[task resume];

// Wait for the connection to succeed and ensure a notification was posted
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error)
[self waitForExpectationsWithTimeout:30.0 handler:^(NSError *error)
{
if (error)
{
Expand Down Expand Up @@ -288,7 +288,7 @@ - (void)testPinningValidationFailedChainNotTrusted
[task resume];

// Wait for the connection to succeed and ensure a notification was posted
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error)
[self waitForExpectationsWithTimeout:30.0 handler:^(NSError *error)
{
if (error)
{
Expand Down Expand Up @@ -333,7 +333,7 @@ - (void)testPinningValidationFailedChainNotTrustedAndNotPinned
[task resume];

// Wait for the connection to succeed and ensure a notification was posted
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error)
[self waitForExpectationsWithTimeout:30.0 handler:^(NSError *error)
{
if (error)
{
Expand Down
2 changes: 1 addition & 1 deletion TrustKitTests/TSKEndToEndSwizzlingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ - (void)test
[task2 resume];

// Wait for the connection to succeed and ensure a notification was posted
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error)
[self waitForExpectationsWithTimeout:30.0 handler:^(NSError *error)
{
if (error)
{
Expand Down
4 changes: 4 additions & 0 deletions TrustKitTests/TSKPinningValidatorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ - (void)tearDown
// Pin to any of CA, Intermediate CA and Leaf certificates public keys (all valid) and ensure it succeeds
- (void)testVerifyAgainstAnyPublicKey
{
#if TARGET_OS_IPHONE
id mockApplication = OCMClassMock([UIApplication class]);
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication);

// Mock isProtectedDataAvailable to return YES
OCMStub([mockApplication isProtectedDataAvailable]).andReturn(YES);
#endif

// Create a valid server trust
SecCertificateRef certChainArray[1] = {_leafCertificate};
Expand Down Expand Up @@ -172,8 +174,10 @@ - (void)testVerifyAgainstAnyPublicKey

CFRelease(trust);

#if TARGET_OS_IPHONE
OCMVerify([mockApplication isProtectedDataAvailable]);
[mockApplication stopMocking];
#endif
}


Expand Down
2 changes: 2 additions & 0 deletions TrustKitTests/TSKPublicKeyAlgorithmTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ - (void)testExtractEcDsaSecp384r1
}


#if TARGET_OS_IPHONE
- (void)testSPKICacheThreadSafetyAndProtectedData
{
XCTestExpectation *expectation = [self expectationWithDescription:@"Cache operations completed"];
Expand Down Expand Up @@ -197,5 +198,6 @@ - (void)testSPKICacheThreadSafetyAndProtectedDataDoesntCrash

[self waitForExpectationsWithTimeout:5.0 handler:nil];
}
#endif

@end
26 changes: 26 additions & 0 deletions scripts/build_xcframework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

. "$(dirname "$0")/lib.sh"

ARCHIVES_DIR="output/archives"
XCFRAMEWORK="output/TrustKit.xcframework"
ZIP="output/TrustKit-static.zip"
rm -rf "$ARCHIVES_DIR" "$XCFRAMEWORK" "$ZIP"

FRAMEWORKS=()
for PLATFORM in ios ios-simulator macos tvos tvos-simulator watchos watchos-simulator; do
configure_platform "$PLATFORM"
xcodebuild_pretty archive \
-project TrustKit.xcodeproj \
-scheme "$SCHEME" \
-destination "generic/platform=${PLATFORM_NAME}" \
-archivePath "${ARCHIVES_DIR}/${PLATFORM}.xcarchive" \
SKIP_INSTALL=NO \
MACH_O_TYPE=staticlib \
CODE_SIGNING_ALLOWED=NO \
"$@"
FRAMEWORKS+=(-framework "${ARCHIVES_DIR}/${PLATFORM}.xcarchive/Products/Library/Frameworks/TrustKit.framework")
done

xcodebuild -create-xcframework "${FRAMEWORKS[@]}" -output "$XCFRAMEWORK"
ditto -c -k --keepParent "$XCFRAMEWORK" "$ZIP"
34 changes: 34 additions & 0 deletions scripts/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

cd "$(dirname "$0")/.."

xcodebuild_pretty() {
if ! command -v xcbeautify >/dev/null 2>&1; then
xcodebuild "$@"
elif [[ -n "${GITHUB_ACTIONS:-}" ]]; then
NSUnbufferedIO=YES xcodebuild "$@" 2>&1 | xcbeautify --preserve-unbeautified --renderer github-actions
else
NSUnbufferedIO=YES xcodebuild "$@" 2>&1 | xcbeautify --preserve-unbeautified
fi
}

configure_platform() {
SIMULATOR=""
case "$1" in
ios) SCHEME="TrustKit"; PLATFORM_NAME="iOS" ;;
ios-simulator) SCHEME="TrustKit"; PLATFORM_NAME="iOS Simulator"; SIMULATOR="iPhone 17"; SIMULATOR_SDK="iphonesimulator" ;;
macos) SCHEME="TrustKit OS X"; PLATFORM_NAME="macOS" ;;
tvos) SCHEME="TrustKit tvOS"; PLATFORM_NAME="tvOS" ;;
tvos-simulator) SCHEME="TrustKit tvOS"; PLATFORM_NAME="tvOS Simulator"; SIMULATOR="Apple TV 4K (3rd generation)"; SIMULATOR_SDK="appletvsimulator" ;;
watchos) SCHEME="TrustKit watchOS"; PLATFORM_NAME="watchOS" ;;
watchos-simulator) SCHEME="TrustKit watchOS"; PLATFORM_NAME="watchOS Simulator" ;;
*)
echo "Unknown platform '$1'; expected ios, ios-simulator, macos, tvos, tvos-simulator, watchos or watchos-simulator" >&2
exit 1
;;
esac
}
22 changes: 22 additions & 0 deletions scripts/run_unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

. "$(dirname "$0")/lib.sh"

PLATFORM="${1:?usage: $0 <ios-simulator|macos|tvos-simulator> [xcodebuild arguments...]}"
shift
configure_platform "$PLATFORM"

RESULT_BUNDLE="output/${PLATFORM}-tests.xcresult"
rm -rf "$RESULT_BUNDLE"

DESTINATION="platform=${PLATFORM_NAME}"
if [[ -n "$SIMULATOR" ]]; then
DESTINATION+=",name=${SIMULATOR},OS=$(xcrun --sdk "$SIMULATOR_SDK" --show-sdk-version)"
fi

xcodebuild_pretty test \
-project TrustKit.xcodeproj \
-scheme "$SCHEME" \
-destination "$DESTINATION" \
-resultBundlePath "$RESULT_BUNDLE" \
"$@"
Loading
Loading