Current section
Files
Jump to
Current section
Files
src/neon@testing.erl
-module(neon@testing).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/neon/testing.gleam").
-export([rsa/1, ec/1, pkix_test_data/2]).
-export_type([key_type/0, ec_curve/0, cert_data/0, pkix_test_data/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-opaque key_type() :: {rsa, integer()} | {ec, ec_curve()}.
-type ec_curve() :: secp256r1 | secp384r1 | secp521r1.
-type cert_data() :: {cert_data,
bitstring(),
neon@ssl:private_key(),
list(bitstring())}.
-type pkix_test_data() :: {pkix_test_data, cert_data(), cert_data()}.
-file("src/neon/testing.gleam", 27).
?DOC(" Creates a key type for RSA with the given bit size.\n").
-spec rsa(integer()) -> key_type().
rsa(Size) ->
{rsa, Size}.
-file("src/neon/testing.gleam", 32).
?DOC(" Creates a key type for EC with the given named curve.\n").
-spec ec(ec_curve()) -> key_type().
ec(Curve) ->
{ec, Curve}.
-file("src/neon/testing.gleam", 42).
?DOC(
" Generates test certificate data for the given key type.\n"
"\n"
" The `server_name` parameter sets the dNSName in the server's peer\n"
" certificate. Use this same name as the SNI hostname when connecting\n"
" with `verify_peer` so the hostname check passes.\n"
).
-spec pkix_test_data(key_type(), binary()) -> pkix_test_data().
pkix_test_data(Key_type, Server_name) ->
public_key_ffi:pkix_test_data(Key_type, Server_name).