Checking the Validity of a Certificate
Certificates are valid for a specified period of time, encoded in the certificate. The internal certificate verification algorithm checks that the certificate is valid before proceeding, but your application can also explicitly check a certificate before passing it into a context.
RWX509Certificate has two functions for checking certificate validity with respect to a specified date and time:
*RWX509Certificate::isValid(const RWDateTime&) returns true if the certificate is valid relative to the date and time, and returns false otherwise.
*RWX509Certificate::throwIfNotValid(const RWDateTime&) throws an exception if the certificate is not valid. For more information, see RWX509Certificate in the SourcePro API Reference Guide.
The RWDateTime parameter in Example 5 defaults to the current date and time.
Example 5 – Using RWX509Certificate
RWX509Certificate cert("server.pem");
RWDateTime longAgo("March 23, 1975", RWDateTime::setDate);
 
if(cert.isValid()) { cout << "Certificate is valid today!" << endl;
} else {
cout << "Certificate is not valid today." << endl;
}
if(cert.isValid(longAgo)) {
cout << "Certificate was valid on March 23, 1975" << endl;
} else {
cout << "Certificate was not valid on March 23, 1975" << endl;
}