Created
November 11, 2014 17:39
-
-
Save phatblat/843ffecd28ffc84d6442 to your computer and use it in GitHub Desktop.
An example of configuring libgit2 on iOS to use the root CA cert for GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: