Certificate
public final class Certificate : TokenObject
Class that describes a certificate object. Inherits from TokenObject.
-
Returns the subject name of the certificate.
Note:
The string is extracted from the last (most specific) occurrence of common name field. If no such field is defined, the implementation falls back on the first organizational unit name field, or the first organization name field, or the first email address field (in this order).
Declaration
Swift
public func getSubject() -> StringReturn Value
The subject name of the certificate.
-
Returns the issuer name of the certificate.
Note:
The string is obtained by using the same rules as for
Certificate.getSubject().Declaration
Swift
public func getIssuer() -> StringReturn Value
The issuer name of the certificate.
-
Returns the certificate start of validity date.
Declaration
Swift
public func getNotBefore() -> StringReturn Value
Start of validity date, given as a ISO-8601 string.
-
Returns the certificate end of validity date.
Declaration
Swift
public func getNotAfter() -> StringReturn Value
End of validity date, given as a ISO-8601 string.
-
Fetch the certificate serial number.
Declaration
Swift
public func getSerial(completionHandler: @escaping (_ serial: String?, _ error: NSError?) -> Void)Parameters
completionHandlerThe completion handler block to be called as soon as the serial number is retrieved.
- serial
String?: The serial number of the certificate. - error
NSError:nilif the serial number is retrieved successfully; otherwise an error encapsulates the reason of failure.
Note
The completion handler is executed on the same type ofDispatchQueueas in the calling code. - serial
-
Gets the
SecCertificateobject, created from currentCertificate.Example
func addCertificateToKeychain(certificate: Certificate) { certificate.getSecCertificate { secCertificate, error in if let error = error { print("fail to get SecCertificate " + error.localizedDescription) } else { SecCertificateAddToKeychain(secCertificate, nil) } } }Declaration
Swift
public func getSecCertificate(completionHandler: @escaping (_ secCertificate: SecCertificate?, _ error: NSError?) -> Void)Parameters
completionHandlerThe completion handler block to be called as soon as the
SecCertificateis created. It takes the following parameters:- secCertificate
SecCertificate?: The createdSecCertificateobject. - error
NSError?:nilif the operation was completed successfully; otherwise an error encapsulates the reason of failure.
Note
The completion handler is executed on the same type ofDispatchQueueas in the calling code. - secCertificate