Commit 45245cb2 authored by Mingtao Yang's avatar Mingtao Yang Committed by Facebook Github Bot

Add X509_REVOKED_get0_* OpenSSL shims

Reviewed By: yfeldblum

Differential Revision: D5509756

fbshipit-source-id: 0b9581dafb073c5e3e5a229c032c6cf272ceb2e0
parent cd2511af
......@@ -392,6 +392,14 @@ void OPENSSL_cleanup() {
ERR_clear_error();
}
const ASN1_INTEGER* X509_REVOKED_get0_serialNumber(const X509_REVOKED* r) {
return r->serialNumber;
}
const ASN1_TIME* X509_REVOKED_get0_revocationDate(const X509_REVOKED* r) {
return r->revocationDate;
}
#endif // !FOLLY_OPENSSL_IS_110
}
}
......
......@@ -173,6 +173,9 @@ using OPENSSL_INIT_SETTINGS = void;
int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS* settings);
void OPENSSL_cleanup();
const ASN1_INTEGER* X509_REVOKED_get0_serialNumber(const X509_REVOKED* r);
const ASN1_TIME* X509_REVOKED_get0_revocationDate(const X509_REVOKED* r);
#endif
#if FOLLY_OPENSSL_IS_110
......
......@@ -14,6 +14,8 @@
* limitations under the License.
*/
#include <ctime>
#include <folly/portability/GTest.h>
#include <folly/ssl/OpenSSLPtrTypes.h>
......@@ -75,3 +77,33 @@ TEST(OpenSSLPortabilityTest, TestEcdsaSigPortability) {
EXPECT_FALSE(BN_cmp(r, r_actual));
EXPECT_FALSE(BN_cmp(s, s_actual));
}
TEST(OpenSSLPortabilityTest, TestX509RevokedApi) {
X509_REVOKED* rev = X509_REVOKED_new();
ASN1_INTEGER* serial = ASN1_INTEGER_new();
ASN1_INTEGER_set(serial, 1234L);
ASN1_TIME* revocation_date = ASN1_TIME_new();
time_t t = time(nullptr);
ASN1_TIME_set(revocation_date, t);
X509_REVOKED_set_serialNumber(rev, serial);
X509_REVOKED_set_revocationDate(rev, revocation_date);
const ASN1_INTEGER* retrieved_serial = X509_REVOKED_get0_serialNumber(rev);
const ASN1_TIME* retrieved_date = X509_REVOKED_get0_revocationDate(rev);
EXPECT_EQ(0, ASN1_INTEGER_cmp(serial, retrieved_serial));
int diff_days;
int diff_secs;
ASN1_TIME_diff(&diff_days, &diff_secs, revocation_date, retrieved_date);
EXPECT_EQ(0, diff_days);
EXPECT_EQ(0, diff_secs);
ASN1_INTEGER_free(serial);
ASN1_TIME_free(revocation_date);
X509_REVOKED_free(rev);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment