MOLCodesignChecker
提供了一种在 Objective-C 中进行代码签名验证的简单方法
用法
#import <MOLCertificate/MOLCertificate.h>
#import <MOLCodesignChecker/MOLCodesignChecker.h>
- (BOOL)validateMySignature {
MOLCodesignChecker *csInfo = [[MOLCodesignChecker alloc] initWithSelf];
if (csInfo) {
// I'm signed! Check the certificate
NSLog(@"%@, %@", csInfo.leafCertificate, csInfo.leafCertificate.SHA256);
return YES;
}
return NO;
}
- (BOOL)validateFile:(NSString *)filePath {
MOLCodesignChecker *csInfo = [[MOLCodesignChecker alloc] initWithBinaryPath:filePath];
if (csInfo) {
// I'm signed! Check the certificate
NSLog(@"%@, %@", csInfo.leafCertificate, csInfo.leafCertificate.SHA256);
return YES;
}
return NO;
}
安装
使用 CocoaPods
将以下行添加到您的 Podfile 中
pod 'MOLCodesignChecker'
Bazel
使用请将以下内容添加到您的 WORKSPACE 文件中
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
# Needed for MOLCodesignChecker
git_repository(
name = "MOLCertificate",
remote = "https://github.com/google/macops-molcertificate.git",
tag = "v2.0",
)
git_repository(
name = "MOLCodesignChecker",
remote = "https://github.com/google/macops-molcodesignchecker.git",
tag = "v2.1",
)
然后在您的 BUILD 文件中,将 MOLCodesignChecker 作为依赖项添加
objc_library( name = "MyAwesomeApp_lib", srcs = ["src/MyAwesomeApp.m", "src/MyAwesomeApp.h"], deps = ["@MOLCodesignChecker//:MOLCodesignChecker"], )
文档
参考文档位于 CocoaDocs.org
http://cocoadocs.org/docsets/MOLCodesignChecker
贡献
欢迎对这个库进行修补。请参见 CONTRIBUTING 文件。