|
|
@ -73,16 +73,30 @@ class ResignApp(object): |
|
|
|
result["err_info"] = e |
|
|
|
result["err_info"] = e |
|
|
|
return False, result |
|
|
|
return False, result |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_cert(self): |
|
|
|
|
|
|
|
for file in [self.app_dev_p12, self.app_dev_p12 + '.pwd', self.my_local_key, self.app_dev_pem]: |
|
|
|
|
|
|
|
if os.path.exists(file): |
|
|
|
|
|
|
|
os.rename(file, file + '.' + get_format_time() + '.bak') |
|
|
|
|
|
|
|
os.rename(file + '.bak', file) |
|
|
|
|
|
|
|
|
|
|
|
def make_cert_from_p12(self, password, p12_content=None): |
|
|
|
def make_cert_from_p12(self, password, p12_content=None): |
|
|
|
result = {} |
|
|
|
result = {} |
|
|
|
try: |
|
|
|
try: |
|
|
|
if p12_content: |
|
|
|
if p12_content: |
|
|
|
|
|
|
|
p12_content_list = p12_content.split('data:application/x-pkcs12;base64,') |
|
|
|
|
|
|
|
if len(p12_content_list) == 2: |
|
|
|
with open(self.app_dev_p12 + '.bak', 'wb+') as f: |
|
|
|
with open(self.app_dev_p12 + '.bak', 'wb+') as f: |
|
|
|
f.write(base64.b64decode(p12_content.split('data:application/x-pkcs12;base64,')[1])) |
|
|
|
f.write(base64.b64decode(p12_content.split('data:application/x-pkcs12;base64,')[1])) |
|
|
|
if password: |
|
|
|
if password: |
|
|
|
with open(self.app_dev_p12 + '.pwd.bak', 'w') as f: |
|
|
|
with open(self.app_dev_p12 + '.pwd.bak', 'w') as f: |
|
|
|
f.write(password) |
|
|
|
f.write(password) |
|
|
|
p12 = load_pkcs12(open(self.app_dev_p12, 'rb').read(), password) |
|
|
|
else: |
|
|
|
|
|
|
|
result["err_info"] = '非法p12证书文件,请检查' |
|
|
|
|
|
|
|
return False, result |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
result["err_info"] = '证书内容有误,请检查' |
|
|
|
|
|
|
|
return False, result |
|
|
|
|
|
|
|
p12 = load_pkcs12(open(self.app_dev_p12 + '.bak', 'rb').read(), password) |
|
|
|
cert = p12.get_certificate() |
|
|
|
cert = p12.get_certificate() |
|
|
|
if cert.has_expired(): |
|
|
|
if cert.has_expired(): |
|
|
|
result["err_info"] = '证书已经过期' |
|
|
|
result["err_info"] = '证书已经过期' |
|
|
@ -91,16 +105,14 @@ class ResignApp(object): |
|
|
|
f.write(dump_privatekey(FILETYPE_PEM, p12.get_privatekey())) |
|
|
|
f.write(dump_privatekey(FILETYPE_PEM, p12.get_privatekey())) |
|
|
|
with open(self.app_dev_pem + '.bak', 'wb+') as f: |
|
|
|
with open(self.app_dev_pem + '.bak', 'wb+') as f: |
|
|
|
f.write(dump_certificate(FILETYPE_PEM, cert)) |
|
|
|
f.write(dump_certificate(FILETYPE_PEM, cert)) |
|
|
|
for file in [self.app_dev_p12, self.app_dev_p12 + '.pwd', self.my_local_key, self.app_dev_pem]: |
|
|
|
|
|
|
|
if os.path.exists(file): |
|
|
|
|
|
|
|
os.rename(file, file + '.' + get_format_time() + '.bak') |
|
|
|
|
|
|
|
os.rename(file + '.bak', file) |
|
|
|
|
|
|
|
return True, cert.get_version() |
|
|
|
return True, cert.get_version() |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
for file in [self.app_dev_p12, self.app_dev_p12 + '.pwd', self.my_local_key, self.app_dev_pem]: |
|
|
|
for file in [self.app_dev_p12, self.app_dev_p12 + '.pwd', self.my_local_key, self.app_dev_pem]: |
|
|
|
if os.path.exists(file + '.bak'): |
|
|
|
if os.path.exists(file + '.bak'): |
|
|
|
os.remove(file + '.bak') |
|
|
|
os.remove(file + '.bak') |
|
|
|
result["err_info"] = e |
|
|
|
result["err_info"] = e |
|
|
|
|
|
|
|
if 'mac verify failure' in str(e): |
|
|
|
|
|
|
|
result["err_info"] = 'p12 导入密码错误,请检查' |
|
|
|
return False, result |
|
|
|
return False, result |
|
|
|
|
|
|
|
|
|
|
|
def sign(self, new_profile, org_ipa, new_ipa, info_plist_properties=None): |
|
|
|
def sign(self, new_profile, org_ipa, new_ipa, info_plist_properties=None): |
|
|
|