s2n_openssl_x509.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #include "crypto/s2n_openssl_x509.h"
  16. #include "api/s2n.h"
  17. S2N_CLEANUP_RESULT s2n_openssl_x509_stack_pop_free(STACK_OF(X509) **cert_chain)
  18. {
  19. RESULT_ENSURE_REF(*cert_chain);
  20. sk_X509_pop_free(*cert_chain, X509_free);
  21. *cert_chain = NULL;
  22. return S2N_RESULT_OK;
  23. }
  24. S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **time_ptr)
  25. {
  26. /* The ANS1_*TIME structs are just typedef wrappers around ASN1_STRING
  27. *
  28. * The ASN1_TIME, ASN1_UTCTIME and ASN1_GENERALIZEDTIME structures are
  29. * represented as an ASN1_STRING internally and can be freed up using
  30. * ASN1_STRING_free().
  31. * https://www.openssl.org/docs/man1.1.1/man3/ASN1_TIME_to_tm.html
  32. */
  33. RESULT_ENSURE_REF(*time_ptr);
  34. ASN1_STRING_free((ASN1_STRING *) *time_ptr);
  35. *time_ptr = NULL;
  36. return S2N_RESULT_OK;
  37. }