Skip to content

Commit

Permalink
Add otpbp_pubkey_ocsp with otp_cert/1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledest committed Nov 12, 2023
1 parent 619f7d9 commit 75d649c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ Funs = [{application, get_supervisor, 1},
{proc_lib, start_monitor, 5},
{proplists, to_map, 1},
{proplists, to_map, 2},
{pubkey_ocsp, otp_cert, 1},
{pubkey_os_cacerts, clear, 0},
{pubkey_os_cacerts, format_error, 2},
{pubkey_os_cacerts, get, 0},
Expand Down
1 change: 1 addition & 0 deletions src/otpbp_pt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
{{proc_lib, start_monitor, [3, 4, 5]}, otpbp_proc_lib},
{{proplists, from_map, 1}, {maps, to_list}}, % OTP 24.0
{{proplists, to_map, [1, 2]}, otpbp_proplists},
{{pubkey_ocsp, otp_cert, 1}, otpbp_pubkey_ocsp},
{{pubkey_os_cacerts, [clear, get], 0}, otpbp_pubkey_os_cacerts},
{{pubkey_os_cacerts, load, [0, 1]}, otpbp_pubkey_os_cacerts},
{{pubkey_os_cacerts, format_error, 2}, otpbp_pubkey_os_cacerts},
Expand Down
14 changes: 14 additions & 0 deletions src/otpbp_pubkey_ocsp.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-module(otpbp_pubkey_ocsp).

-include_lib("public_key/include/OTP-PUB-KEY.hrl").

-ifndef(HAVE_pubkey_ocsp__otp_cert_1).
% OTP < 26.0
-export([otp_cert/1]).
-endif.

-ifndef(HAVE_pubkey_ocsp__otp_cert_1).
otp_cert(#'OTPCertificate'{} = Cert) -> Cert;
otp_cert(#'Certificate'{} = Cert) -> public_key:pkix_decode_cert(public_key:der_encode('Certificate', Cert), otp);
otp_cert(CertDer) when is_binary(CertDer) -> public_key:pkix_decode_cert(CertDer, otp).
-endif.

0 comments on commit 75d649c

Please sign in to comment.