10 | #import "../TrustKit/Swizzling/TSKNSURLSessionDelegateProxy.h"
11 | #import "../TrustKit/Swizzling/TSKNSURLConnectionDelegateProxy.m"
12 |
13 | @interface TSKSwizzlingTests : XCTestCase
14 |
15 | @end
16 |
17 |
18 | /* Basic tests to ensure RSSwizzle does not trigger a crash because a method we are hooking has changed
19 | */
20 | @implementation TSKSwizzlingTests
21 |
22 | - (void)setUp {
23 | [super setUp];
24 | }
25 |
26 | - (void)tearDown {
27 | [super tearDown];
28 | }
29 |
30 |
31 | - (void)testNSURLSession
32 | {
33 | NSDictionary *trustKitConfig =
34 | @{
35 | kTSKPinnedDomains :
36 | @{
37 | @"www.datatheorem.com" : @{
38 | kTSKEnforcePinning : @YES,
39 | kTSKPublicKeyHashes : @[@"58qRu/uxh4gFezqAcERupSkRYBlBAvfcw7mEjGPLnNU=", // CA key
40 | @"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" // Fake key
41 | ]}}};
42 |
43 | TrustKit *trustKit = [[TrustKit alloc] initWithConfiguration:trustKitConfig];
44 |
45 | [TSKNSURLSessionDelegateProxy swizzleNSURLSessionConstructors:trustKit];
46 |
47 | }
48 |
49 |
50 | - (void)testNSURLConnection
51 | {
52 | NSDictionary *trustKitConfig =
53 | @{
54 | kTSKPinnedDomains :
55 | @{
56 | @"www.datatheorem.com" : @{
57 | kTSKEnforcePinning : @YES,
58 | kTSKPublicKeyHashes : @[@"58qRu/uxh4gFezqAcERupSkRYBlBAvfcw7mEjGPLnNU=", // CA key
59 | @"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" // Fake key
60 | ]}}};
61 |
62 | TrustKit *trustKit = [[TrustKit alloc] initWithConfiguration:trustKitConfig];
63 |
64 | [TSKNSURLConnectionDelegateProxy swizzleNSURLConnectionConstructors:trustKit];
65 |
66 | }
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/docs/TrustKit-BH2015.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/TrustKit-BH2015.pdf
--------------------------------------------------------------------------------
/docs/documentation-readme.md:
--------------------------------------------------------------------------------
1 | # TrustKit Documentation
2 |
3 | TrustKit is an open source framework that makes it easy to deploy SSL public key pinning in any iOS, macOS, tvOS or watchOS App.
4 |
5 | This is the API documentation for TrustKit. A "Getting Started" guide is available at https://github.com/datatheorem/TrustKit/blob/master/docs/getting-started.md.
6 |
7 | TrustKit exposes two core classes for enabling SSL pinning in an App:
8 |
9 | * `TrustKit` for configuring an SSL pinning policy and initializing the framework.
10 | * `TSKPinningValidator`, for validating a server's certificate chain against an SSL pinning policy.
11 |
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleIdentifier
6 | com.jazzy.trustkit
7 | CFBundleName
8 | TrustKit
9 | DocSetPlatformFamily
10 | trustkit
11 | isDashDocset
12 |
13 | dashIndexFilePath
14 | index.html
15 | isJavaScriptEnabled
16 |
17 | DashDocSetFamily
18 | dashtoc
19 |
20 |
21 |
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/carat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/carat.png
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/dash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/dash.png
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/gh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/gh.png
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/spinner.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/img/spinner.gif
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/js/jazzy.js:
--------------------------------------------------------------------------------
1 | window.jazzy = {'docset': false}
2 | if (typeof window.dash != 'undefined') {
3 | document.documentElement.className += ' dash'
4 | window.jazzy.docset = true
5 | }
6 | if (navigator.userAgent.match(/xcode/i)) {
7 | document.documentElement.className += ' xcode'
8 | window.jazzy.docset = true
9 | }
10 |
11 | function toggleItem($link, $content) {
12 | var animationDuration = 300;
13 | $link.toggleClass('token-open');
14 | $content.slideToggle(animationDuration);
15 | }
16 |
17 | function itemLinkToContent($link) {
18 | return $link.parent().parent().next();
19 | }
20 |
21 | // On doc load + hash-change, open any targetted item
22 | function openCurrentItemIfClosed() {
23 | if (window.jazzy.docset) {
24 | return;
25 | }
26 | var $link = $(`.token[href="${location.hash}"]`);
27 | $content = itemLinkToContent($link);
28 | if ($content.is(':hidden')) {
29 | toggleItem($link, $content);
30 | }
31 | }
32 |
33 | $(openCurrentItemIfClosed);
34 | $(window).on('hashchange', openCurrentItemIfClosed);
35 |
36 | // On item link ('token') click, toggle its discussion
37 | $('.token').on('click', function(event) {
38 | if (window.jazzy.docset) {
39 | return;
40 | }
41 | var $link = $(this);
42 | toggleItem($link, itemLinkToContent($link));
43 |
44 | // Keeps the document from jumping to the hash.
45 | var href = $link.attr('href');
46 | if (history.pushState) {
47 | history.pushState({}, '', href);
48 | } else {
49 | location.hash = href;
50 | }
51 | event.preventDefault();
52 | });
53 |
54 | // Clicks on links to the current, closed, item need to open the item
55 | $("a:not('.token')").on('click', function() {
56 | if (location == this.href) {
57 | openCurrentItemIfClosed();
58 | }
59 | });
60 |
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/Documents/js/jazzy.search.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | var $typeahead = $('[data-typeahead]');
3 | var $form = $typeahead.parents('form');
4 | var searchURL = $form.attr('action');
5 |
6 | function displayTemplate(result) {
7 | return result.name;
8 | }
9 |
10 | function suggestionTemplate(result) {
11 | var t = '';
12 | t += '' + result.name + '';
13 | if (result.parent_name) {
14 | t += '' + result.parent_name + '';
15 | }
16 | t += '
';
17 | return t;
18 | }
19 |
20 | $typeahead.one('focus', function() {
21 | $form.addClass('loading');
22 |
23 | $.getJSON(searchURL).then(function(searchData) {
24 | const searchIndex = lunr(function() {
25 | this.ref('url');
26 | this.field('name');
27 | this.field('abstract');
28 | for (const [url, doc] of Object.entries(searchData)) {
29 | this.add({url: url, name: doc.name, abstract: doc.abstract});
30 | }
31 | });
32 |
33 | $typeahead.typeahead(
34 | {
35 | highlight: true,
36 | minLength: 3,
37 | autoselect: true
38 | },
39 | {
40 | limit: 10,
41 | display: displayTemplate,
42 | templates: { suggestion: suggestionTemplate },
43 | source: function(query, sync) {
44 | const lcSearch = query.toLowerCase();
45 | const results = searchIndex.query(function(q) {
46 | q.term(lcSearch, { boost: 100 });
47 | q.term(lcSearch, {
48 | boost: 10,
49 | wildcard: lunr.Query.wildcard.TRAILING
50 | });
51 | }).map(function(result) {
52 | var doc = searchData[result.ref];
53 | doc.url = result.ref;
54 | return doc;
55 | });
56 | sync(results);
57 | }
58 | }
59 | );
60 | $form.removeClass('loading');
61 | $typeahead.trigger('focus');
62 | });
63 | });
64 |
65 | var baseURL = searchURL.slice(0, -"search.json".length);
66 |
67 | $typeahead.on('typeahead:select', function(e, result) {
68 | window.location = baseURL + result.url;
69 | });
70 | });
71 |
--------------------------------------------------------------------------------
/docs/documentation/docsets/TrustKit.docset/Contents/Resources/docSet.dsidx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/docsets/TrustKit.docset/Contents/Resources/docSet.dsidx
--------------------------------------------------------------------------------
/docs/documentation/img/carat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/img/carat.png
--------------------------------------------------------------------------------
/docs/documentation/img/dash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/img/dash.png
--------------------------------------------------------------------------------
/docs/documentation/img/gh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/img/gh.png
--------------------------------------------------------------------------------
/docs/documentation/img/spinner.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/documentation/img/spinner.gif
--------------------------------------------------------------------------------
/docs/documentation/js/jazzy.js:
--------------------------------------------------------------------------------
1 | window.jazzy = {'docset': false}
2 | if (typeof window.dash != 'undefined') {
3 | document.documentElement.className += ' dash'
4 | window.jazzy.docset = true
5 | }
6 | if (navigator.userAgent.match(/xcode/i)) {
7 | document.documentElement.className += ' xcode'
8 | window.jazzy.docset = true
9 | }
10 |
11 | function toggleItem($link, $content) {
12 | var animationDuration = 300;
13 | $link.toggleClass('token-open');
14 | $content.slideToggle(animationDuration);
15 | }
16 |
17 | function itemLinkToContent($link) {
18 | return $link.parent().parent().next();
19 | }
20 |
21 | // On doc load + hash-change, open any targetted item
22 | function openCurrentItemIfClosed() {
23 | if (window.jazzy.docset) {
24 | return;
25 | }
26 | var $link = $(`.token[href="${location.hash}"]`);
27 | $content = itemLinkToContent($link);
28 | if ($content.is(':hidden')) {
29 | toggleItem($link, $content);
30 | }
31 | }
32 |
33 | $(openCurrentItemIfClosed);
34 | $(window).on('hashchange', openCurrentItemIfClosed);
35 |
36 | // On item link ('token') click, toggle its discussion
37 | $('.token').on('click', function(event) {
38 | if (window.jazzy.docset) {
39 | return;
40 | }
41 | var $link = $(this);
42 | toggleItem($link, itemLinkToContent($link));
43 |
44 | // Keeps the document from jumping to the hash.
45 | var href = $link.attr('href');
46 | if (history.pushState) {
47 | history.pushState({}, '', href);
48 | } else {
49 | location.hash = href;
50 | }
51 | event.preventDefault();
52 | });
53 |
54 | // Clicks on links to the current, closed, item need to open the item
55 | $("a:not('.token')").on('click', function() {
56 | if (location == this.href) {
57 | openCurrentItemIfClosed();
58 | }
59 | });
60 |
--------------------------------------------------------------------------------
/docs/documentation/js/jazzy.search.js:
--------------------------------------------------------------------------------
1 | $(function(){
2 | var $typeahead = $('[data-typeahead]');
3 | var $form = $typeahead.parents('form');
4 | var searchURL = $form.attr('action');
5 |
6 | function displayTemplate(result) {
7 | return result.name;
8 | }
9 |
10 | function suggestionTemplate(result) {
11 | var t = '';
12 | t += '' + result.name + '';
13 | if (result.parent_name) {
14 | t += '' + result.parent_name + '';
15 | }
16 | t += '
';
17 | return t;
18 | }
19 |
20 | $typeahead.one('focus', function() {
21 | $form.addClass('loading');
22 |
23 | $.getJSON(searchURL).then(function(searchData) {
24 | const searchIndex = lunr(function() {
25 | this.ref('url');
26 | this.field('name');
27 | this.field('abstract');
28 | for (const [url, doc] of Object.entries(searchData)) {
29 | this.add({url: url, name: doc.name, abstract: doc.abstract});
30 | }
31 | });
32 |
33 | $typeahead.typeahead(
34 | {
35 | highlight: true,
36 | minLength: 3,
37 | autoselect: true
38 | },
39 | {
40 | limit: 10,
41 | display: displayTemplate,
42 | templates: { suggestion: suggestionTemplate },
43 | source: function(query, sync) {
44 | const lcSearch = query.toLowerCase();
45 | const results = searchIndex.query(function(q) {
46 | q.term(lcSearch, { boost: 100 });
47 | q.term(lcSearch, {
48 | boost: 10,
49 | wildcard: lunr.Query.wildcard.TRAILING
50 | });
51 | }).map(function(result) {
52 | var doc = searchData[result.ref];
53 | doc.url = result.ref;
54 | return doc;
55 | });
56 | sync(results);
57 | }
58 | }
59 | );
60 | $form.removeClass('loading');
61 | $typeahead.trigger('focus');
62 | });
63 | });
64 |
65 | var baseURL = searchURL.slice(0, -"search.json".length);
66 |
67 | $typeahead.on('typeahead:select', function(e, result) {
68 | window.location = baseURL + result.url;
69 | });
70 | });
71 |
--------------------------------------------------------------------------------
/docs/documentation/undocumented.json:
--------------------------------------------------------------------------------
1 | {
2 | "warnings": [
3 |
4 | ],
5 | "source_directory": "/Users/nabla/Documents/ios/TrustKit"
6 | }
--------------------------------------------------------------------------------
/docs/images/linking3_dynamic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/datatheorem/TrustKit/a94f27be00a9811618ff92f0d3fc40dac8211ba7/docs/images/linking3_dynamic.png
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/generate_test_certificates.py:
--------------------------------------------------------------------------------
1 | import trustme
2 |
3 | # Create a CA
4 | ca = trustme.CA()
5 |
6 | # Issue a cert signed by this CA
7 | server_cert = ca.issue_cert(u"www.good.com")
8 |
9 | # Save the PEM-encoded data to a file
10 | ca.cert_pem.write_to_path("GoodRootCA.pem")
11 | server_cert.private_key_and_cert_chain_pem.write_to_path("www.good.com.pem")
12 |
--------------------------------------------------------------------------------