-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfabfile.py
87 lines (69 loc) · 2.38 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import fabric
import fabric.api
fabric.api.env.hosts = ['barb.cs.washington.edu']
fabric.api.env.user = 'jfogarty'
def keys_csr_create():
# Ensure the server has our staging directory
fabric.api.execute(keys_server_prepare)
# Create our private key
fabric.api.run('openssl genrsa -des3 -out {} 2048'.format(
'~/fabric_staging/keys-recaf/private.key'
))
# Create our certificate signing request
fabric.api.run('openssl req -new -key {} -out {} -subj \'/emailAddress={}/CN={}/C={}\''.format(
'~/fabric_staging/keys-recaf/private.key',
'~/fabric_staging/keys-recaf/request.csr',
'James Fogarty',
'US'
))
# Get our key and csr
fabric.api.get(
'~/fabric_staging/keys-recaf/private.key',
'keys/private.key'
)
fabric.api.get(
'~/fabric_staging/keys-recaf/request.csr',
'keys/request.csr'
)
# Delete them from the server
fabric.api.execute(keys_server_clean)
def keys_p12_create():
# Ensure the server has our staging directory
fabric.api.execute(keys_server_prepare)
# Put our key and certificate
fabric.api.put(
'keys/private.key',
'~/fabric_staging/keys-recaf/private.key',
)
fabric.api.put(
'keys/ios_development.cer',
'~/fabric_staging/keys-recaf/ios_development.cer',
)
# Convert the certificate to pem format
fabric.api.run('openssl x509 -in {} -inform DER -out {} -outform PEM'.format(
'~/fabric_staging/keys-recaf/ios_development.cer',
'~/fabric_staging/keys-recaf/ios_development.pem'
))
# Create the p12 file
fabric.api.run('openssl pkcs12 -export -inkey {} -in {} -out {}'.format(
'~/fabric_staging/keys-recaf/private.key',
'~/fabric_staging/keys-recaf/ios_development.pem',
'~/fabric_staging/keys-recaf/ios_development.p12'
))
# Get our p12
fabric.api.get(
'~/fabric_staging/keys-recaf/ios_development.p12',
'keys/ios_development.p12 '
)
# Delete them from the server
fabric.api.execute(keys_server_clean)
def keys_server_clean():
fabric.api.run('rm -rf {}'.format(
'~/fabric_staging/keys-recaf'
))
def keys_server_prepare():
# Ensure the server has our staging directory
fabric.api.run('mkdir -p {}'.format(
'~/fabric_staging/keys-recaf'
))