iOS App 证书监控

最近App Store停止个人申请个人开发者证书,导致公司超级签名无法使用,被迫找第三方证书签名。第三方证书签名不稳定,存在证书被查封的风险,为了实时监控iOS是否可以继续使用,特意写了一个脚本来监控证书状态,失效收发送钉钉报警。

监控使用真机监控,需要准备的必要条件:

  • 1、苹果手机

  • 2、苹果系统电脑

  • 3、xcode(可以在App Store直接下载安装)

  • 4、python3 可以在官网直接下载安装

  • 5、ios-deploy (用命令向真机安装 app)

    我们用npm来安装ios-deploy,如果Mac上没有,先安装node:

brew install node
npm install -g ios-deploy

下面直接附上脚本

# -*- coding: utf-8 -*-

import os
from dingtalkchatbot.chatbot import DingtalkChatbot
import time

webhook = 'https://oapi.dingtalk.com/robot/send?access_token=你的token'

xiaoding = DingtalkChatbot(webhook)



def ios():
    type_list = []
    lists = os.listdir('/Users/bitz/Desktop/IOS-app/')
    list_file = lists[1:]
    list_file.sort(key=lambda fn: os.path.getmtime('/Users/xxx/Desktop/IOS-app/' + '/' + fn))  # 按时间排序
    file_new = os.path.join('/Users/xxx/Desktop/IOS-app/', list_file[-1])  # 获取最新的文件保存到file_new
    file_time = os.path.getmtime(file_new)
    now = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())
    print(now)
    # 检测手机连接
    jc = 'ios-deploy -c --no-wifi'
    values = os.system(jc)
    print(int(values >> 8))
    if int(values >> 8) == 0:
        shell = 'ios-deploy --uninstall --justlaunch --bundle {}'.format(file_new)
        val = os.system(shell)
        print('状态:' + str(val >> 8))
        if str(val >> 8) != '1':
            type_list.append(1)
        else:
            type_list.append(0)

    else:
        print('手机与电脑连接出现问题!!!')

    xiaoding.send_text(msg="IOS签名包可能掉签了!!!" + str(val >> 8))
    print(now + 'IOS签名包可能掉签了!!!')

while True:
    ios()
    time.sleep(600)

你可能感兴趣的:(iOS App 证书监控)