Skip to content

Instantly share code, notes, and snippets.

@phatblat
Created November 11, 2014 17:39
An example of configuring libgit2 on iOS to use the root CA cert for GitHub
#import <git2/common.h>
NSString *const CACertificateFile_DigiCert = @"DigiCert High Assurance EV Root CA.pem";
NSString *const certFilePath = [[NSBundle mainBundle].bundlePath stringByAppendingPathComponent:CACertificateFile_DigiCert];
NSLog(@"Loading certificate: %@", certFilePath);
const char *file = certFilePath.UTF8String;
const char *path = NULL;
int returnValue = git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, file, path);
if (returnValue != 0) {
NSLog(@"Error setting SSL certificate location");
}
@PeqNP
Copy link

PeqNP commented Nov 27, 2014

Thank you! I just wanted to point out to those that don't know what a .pem is; it is a base64 encoded file that usually starts with ----BEGIN. In my case I downloaded the "DigiCert High Assurance EV Root CA" crt, from https://www.digicert.com/digicert-root-certificates.htm, and ran the following command to convert it to a .pem file:

$ openssl x509 -inform DER -outform PEM -in DigiCertHighAssuranceEVRootCA.crt -out DigiCertHighAssuranceEVRootCA.pem

@lukasredev
Copy link

Thank you very much 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment