iostrust 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/bin/iostrust +31 -0
- data/lib/iostrust.rb +28 -0
- data/lib/iostrust/certificate.rb +50 -0
- data/lib/iostrust/simulator.rb +63 -0
- data/lib/iostrust/version.rb +3 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2684b376c7f780f8417574ab988d236ba7beb0a0
|
4
|
+
data.tar.gz: 15ecb090c9ce166fd5a98e10c83e69426adf37f1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e96ab505cadcce56ac7338c4421e0af6beefd8f8ad02009710cf60c5ca770573da47b9de8592a59623a2a74859ce625d209fc8e2e77db5fe677c0604f61e1bd
|
7
|
+
data.tar.gz: 10adccebf18e8f45e51a52665fb1eb14649481bd58cfc9bbe35dd68e6d9f45a03616a535760e9938c8372a79f627bcb4a202edaafb9f922d974c0c99e9401ece
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2008-2013 TJ Holowaychuk <tj@vision-media.ca>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included
|
14
|
+
in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Iostrust
|
2
|
+
|
3
|
+
This gems allows you to add trust certificate into the ios simulators.
|
4
|
+
|
5
|
+
The work is based on the *IOSTrustStore Structure* specification file
|
6
|
+
from https://https://github.com/ADVTOOLS/ADVTrustStore
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'iostrust'
|
12
|
+
```
|
13
|
+
|
14
|
+
# Usage
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
iostrust add ./cert_1.crt ./cert_2.crt
|
18
|
+
```
|
19
|
+
## License
|
20
|
+
|
21
|
+
This project is available under the MIT license. See LICENSE for details.
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
data/bin/iostrust
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander/import'
|
5
|
+
require 'iostrust'
|
6
|
+
|
7
|
+
program :name, 'ios Trust'
|
8
|
+
program :version, Iostrust::VERSION.to_s
|
9
|
+
program :description, 'Add cert to iOS device simulator trusted key store'
|
10
|
+
|
11
|
+
default_command :add
|
12
|
+
|
13
|
+
command :add do |c|
|
14
|
+
c.syntax = 'iostrust add'
|
15
|
+
c.action do |args|
|
16
|
+
|
17
|
+
if args.size < 1
|
18
|
+
puts "No certificates specified."
|
19
|
+
else
|
20
|
+
certs_to_add = []
|
21
|
+
args.each do |cert_path|
|
22
|
+
certs_to_add << Iostrust::Certificate.new(cert_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
Iostrust.simulators_paths.each do |simulator_path|
|
26
|
+
simulator = Iostrust::Simulator.new(simulator_path)
|
27
|
+
simulator.add_certs(certs_to_add)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/iostrust.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "iostrust/version"
|
2
|
+
require "iostrust/simulator"
|
3
|
+
require "iostrust/certificate"
|
4
|
+
|
5
|
+
module Iostrust
|
6
|
+
private
|
7
|
+
SIMULATOR_HOME_LIBRARY_PATTERNS = [
|
8
|
+
"Application Support/iPhone Simulator/3.*/Library/",
|
9
|
+
"Application Support/iPhone Simulator/4.*/Library/",
|
10
|
+
"Developer/CoreSimulator/Devices/**/data/Library/",
|
11
|
+
"Application Support/iPhone Simulator/User/Library/"
|
12
|
+
]
|
13
|
+
|
14
|
+
def self.path_for_pattern(pattern)
|
15
|
+
return File.join(Dir.home, 'Library', pattern)
|
16
|
+
end
|
17
|
+
|
18
|
+
public
|
19
|
+
def self.simulators_paths
|
20
|
+
simulators = []
|
21
|
+
SIMULATOR_HOME_LIBRARY_PATTERNS.each do |pattern|
|
22
|
+
found_paths = Dir.glob(path_for_pattern(pattern))
|
23
|
+
simulators.push(*found_paths)
|
24
|
+
end
|
25
|
+
simulators
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'digest/sha1'
|
3
|
+
|
4
|
+
module Iostrust
|
5
|
+
class Certificate
|
6
|
+
|
7
|
+
@@PLIST = <<PLIST
|
8
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
9
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
10
|
+
<plist version="1.0">
|
11
|
+
<array/>
|
12
|
+
</plist>
|
13
|
+
PLIST
|
14
|
+
|
15
|
+
def initialize(cert_path)
|
16
|
+
raw_cert = File.read cert_path
|
17
|
+
@cert = OpenSSL::X509::Certificate.new raw_cert
|
18
|
+
end
|
19
|
+
|
20
|
+
def cert_name
|
21
|
+
@cert.subject.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def tset
|
25
|
+
return @@PLIST
|
26
|
+
end
|
27
|
+
|
28
|
+
def data
|
29
|
+
@cert.to_der
|
30
|
+
end
|
31
|
+
|
32
|
+
def sha1
|
33
|
+
str = Digest::SHA1.hexdigest(data)
|
34
|
+
[str].pack('H*')
|
35
|
+
end
|
36
|
+
|
37
|
+
def subj
|
38
|
+
subj = ""
|
39
|
+
asn_subject = OpenSSL::ASN1.decode(@cert.subject)
|
40
|
+
asn_subject.each do |asn_sub|
|
41
|
+
subj << asn_sub.to_der
|
42
|
+
end
|
43
|
+
subj
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'sqlite3'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'date'
|
4
|
+
require 'openssl'
|
5
|
+
module Iostrust
|
6
|
+
class Simulator
|
7
|
+
|
8
|
+
def initialize(path)
|
9
|
+
@path = File.join(path, 'Keychains/TrustStore.sqlite3')
|
10
|
+
end
|
11
|
+
|
12
|
+
def backup_path
|
13
|
+
"#{@path}.iostrust.backup"
|
14
|
+
end
|
15
|
+
def backup
|
16
|
+
FileUtils.cp_r(@path, backup_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def restore
|
20
|
+
return if not File.exists? backup_path
|
21
|
+
FileUtils.rm_r(@path)
|
22
|
+
FileUtils.mv(backup_path, @path)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def add_cert(cert)
|
27
|
+
puts "Start adding to #{@path}:"
|
28
|
+
|
29
|
+
keychain_dir = File.dirname(@path)
|
30
|
+
is_new_db = !Dir.exists?(keychain_dir)
|
31
|
+
if is_new_db
|
32
|
+
Dir.mkdir keychain_dir
|
33
|
+
else
|
34
|
+
puts "Backup..."
|
35
|
+
backup()
|
36
|
+
end
|
37
|
+
puts "Adding #{cert.cert_name}..."
|
38
|
+
|
39
|
+
SQLite3::Database.new @path do |db|
|
40
|
+
|
41
|
+
sha1 = SQLite3::Blob.new(cert.sha1)
|
42
|
+
subj = SQLite3::Blob.new(cert.subj)
|
43
|
+
tset = SQLite3::Blob.new(cert.tset)
|
44
|
+
data = SQLite3::Blob.new(cert.data)
|
45
|
+
|
46
|
+
begin
|
47
|
+
if is_new_db
|
48
|
+
db.execute "CREATE TABLE tsettings(sha1 BLOB NOT NULL DEFAULT '',subj BLOB NOT NULL DEFAULT '',tset BLOB,data BLOB,PRIMARY KEY(sha1));"
|
49
|
+
end
|
50
|
+
db.execute "INSERT INTO 'tsettings' (sha1, subj, tset, data) VALUES(?,?,?,?)", sha1, subj, tset, data
|
51
|
+
rescue SQLite3::ConstraintException => e
|
52
|
+
puts "Certificates was not added : Already presents"
|
53
|
+
else
|
54
|
+
puts "OK"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_certs(certs)
|
60
|
+
certs.each { |cert| add_cert(cert) }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iostrust
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yannick heinrich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |2-
|
42
|
+
|
43
|
+
iostrust installs a list of certificates in all the simulators located on your computer.
|
44
|
+
It uses sqlite and openssl from the Ruby stdlib.
|
45
|
+
email:
|
46
|
+
- yannick.heinrich@gmail.com
|
47
|
+
executables:
|
48
|
+
- iostrust
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- bin/iostrust
|
55
|
+
- lib/iostrust.rb
|
56
|
+
- lib/iostrust/certificate.rb
|
57
|
+
- lib/iostrust/simulator.rb
|
58
|
+
- lib/iostrust/version.rb
|
59
|
+
homepage: https://github.com/yageek/iostrust
|
60
|
+
licenses: []
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Add certificates in the trust store of the ios simulators
|
82
|
+
test_files: []
|
83
|
+
has_rdoc:
|