google / macops-molcodesignchecker

Simple Objective-C code signature validation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MOLCodesignChecker

Provides an easy way to do code signature validation in Objective-C

Usage

#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;
}

Installation

Using CocoaPods

Add the following line to your Podfile:

pod 'MOLCodesignChecker'

Using Bazel

Add the following to your 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.1",
)

git_repository(
    name = "MOLCodesignChecker",
    remote = "https://github.com/google/macops-molcodesignchecker.git",
    tag = "v2.2",
)

And in your BUILD file, add MOLCodesignChecker as a dependency:

objc_library(
    name = "MyAwesomeApp_lib",
    srcs = ["src/MyAwesomeApp.m", "src/MyAwesomeApp.h"],
    deps = ["@MOLCodesignChecker//:MOLCodesignChecker"],
)

Documentation

Reference documentation is at CocoaDocs.org:

http://cocoadocs.org/docsets/MOLCodesignChecker

Contributing

Patches to this library are very much welcome. Please see the CONTRIBUTING file.

About

Simple Objective-C code signature validation

License:Apache License 2.0


Languages

Language:Objective-C 95.7%Language:Starlark 4.3%