https://github.com/tls-inspector/CertificateKit
CertificateKit for iOS makes working with SSL/TLS certificates a pain-free endeavour!
https://github.com/tls-inspector/CertificateKit
certificate cryptography framework ios ios-library ssl tls x509
Last synced: 3 months ago
JSON representation
CertificateKit for iOS makes working with SSL/TLS certificates a pain-free endeavour!
- Host: GitHub
- URL: https://github.com/tls-inspector/CertificateKit
- Owner: tls-inspector
- License: mit
- Archived: true
- Created: 2016-04-05T03:21:33.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-14T22:45:13.000Z (about 8 years ago)
- Last Synced: 2024-10-23T20:11:27.801Z (8 months ago)
- Topics: certificate, cryptography, framework, ios, ios-library, ssl, tls, x509
- Language: C
- Homepage: https://tlsinspector.com
- Size: 21.1 MB
- Stars: 8
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# CertificateKit
CertificateKit is an advanced iOS library for working with SSL/TLS X.509 certificates. It's primarily used within the [TLS Inspector iOS app](https://tlsinspector.com) but can be used in any iOS project.
The primary goal with CertificateKit is to provide an easy-to-use front-end to OpenSSLs X.509 APIs.
[API Reference](https://tlsinspector.com/docs/index.html)
## Installation
**Due to the complex nature of CertificateKit, it cannot be installed using Cocoapods and must be installed manually.**
1. Download the Latest Release
2. Add the `CertificateKit.framework` file to your project by dragging and dropping it onto the Project Navigator in Xcode## Getting Started
To get a chain of certificates (Root, Intermediate, and Server) for a given URL:
### Objective-C:
```objc
self.chain = [CKCertificateChain new];[self.chain
certificateChainFromURL:[NSURL URLWithString:@"https://tls-inspector.com"]
finished:^(NSError * _Nullable error, CKCertificateChain * _Nullable chain) {
if (error) {
// Do something
}// Is the chain trusted
switch (chain.trusted) {
case CKCertificateChainTrustStatusTrusted:
// Trusted by system
break;
case CKCertificateChainTrustStatusUntrusted:
// Untrusted by system
break;
}// Is the server certificate revoked
if (chain.server.revoked.isRevoked) {
// Print the reason why it was revoked
NSLog(@"%@", chain.server.revoked.reasonString);
}
}];
```### Swift:
```swift
let chain: CKCertificateChain = CKCertificateChain()chain.certificateChain(from: URL(string: "https://tls-inspector.com")!) { (error, chain) in
if error != nil {
// Do something
}// Is the chain trusted
if let trust: CKCertificateChainTrustStatus = chain?.trusted {
switch trust {
case .trusted:
// Trusted by system
break
case .untrusted:
// Untrusted by system
break
}
}// Is the server certificate revoked
if chain?.server?.revoked.isRevoked ?? false {
let reasonString = chain?.server?.revoked.reasonString
print(reasonString)
}
}
```For more information see the [API Reference](https://tlsinspector.com/docs/index.html).