forked from yan12125/python3-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc_rehash.py
More file actions
24 lines (21 loc) · 785 Bytes
/
Copy pathc_rehash.py
File metadata and controls
24 lines (21 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from os.path import abspath, dirname, exists, join
import subprocess
import sys
ssl_cert_src = '/system/etc/security/cacerts'
# This file is installed at $PREFIX/tools/
ssl_cert_dst = join(dirname(dirname(abspath(__file__))), 'etc', 'ssl', 'certs')
if len(sys.argv) == 3:
ssl_cert_src = sys.argv[1]
ssl_cert_dst = sys.argv[2]
for cert in os.listdir(ssl_cert_src):
old_path = join(ssl_cert_src, cert)
new_hash = subprocess.check_output([
'openssl', 'x509', '-noout', '-hash', '-in', old_path
]).strip().decode('ascii')
for index in range(10):
new_path = join(ssl_cert_dst, '%s.%s' % (new_hash, index))
if not exists(new_path):
break
print('%s => %s' % (old_path, new_path))
os.symlink(old_path, new_path)