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() -> String
Return 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() -> String
Return Value
The issuer name of the certificate.
-
Returns the certificate start of validity date.
Declaration
Swift
public func getNotBefore() -> String
Return Value
Start of validity date, given as a ISO-8601 string.
-
Returns the certificate end of validity date.
Declaration
Swift
public func getNotAfter() -> String
Return 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
completionHandler
The completion handler block to be called as soon as the serial number is retrieved.
- serial
String?
: The serial number of the certificate. - error
NSError
:nil
if the serial number is retrieved successfully; otherwise an error encapsulates the reason of failure.
Note
The completion handler is executed on the same type ofDispatchQueue
as in the calling code. - serial
-
Gets the
SecCertificate
object, 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
completionHandler
The completion handler block to be called as soon as the
SecCertificate
is created. It takes the following parameters:- secCertificate
SecCertificate?
: The createdSecCertificate
object. - error
NSError?
:nil
if the operation was completed successfully; otherwise an error encapsulates the reason of failure.
Note
The completion handler is executed on the same type ofDispatchQueue
as in the calling code. - secCertificate