test_qa.c 695 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <assert.h>
  2. #include <string.h>
  3. #include <openssl/x509.h>
  4. #include "qa/qa.h"
  5. void test_get_local_cert(void)
  6. {
  7. X509 *crt;
  8. EVP_PKEY *pkey;
  9. char path[64];
  10. /* get_local_cert() shall return NULL if the file does not exist. */
  11. strcpy(path, "/lifting/me/higher/keeps/me/lifting.crt");
  12. assert(!get_local_cert(path));
  13. strcpy(path, "dummy.crt");
  14. crt = get_local_cert(path);
  15. assert(crt);
  16. pkey = X509_get_pubkey(crt);
  17. assert(pkey);
  18. /*
  19. * The certificate shall make accessible both the modulus and the public
  20. * exponent.
  21. */
  22. assert(pkey->pkey.rsa->n);
  23. assert(pkey->pkey.rsa->e);
  24. }
  25. int main(int argc, char **argv)
  26. {
  27. test_get_local_cert();
  28. return 0;
  29. }