@@ -769,6 +769,73 @@ entry! {
769769 }
770770}
771771
772+ entry ! {
773+ pub fn _SSL_CTX_add_server_custom_ext(
774+ ctx: * mut SSL_CTX ,
775+ ext_type: c_uint,
776+ _add_cb: custom_ext_add_cb,
777+ _free_cb: custom_ext_free_cb,
778+ _add_arg: * mut c_void,
779+ _parse_cb: custom_ext_parse_cb,
780+ _parse_arg: * mut c_void,
781+ ) -> c_int {
782+ let _null_check = try_ref_from_ptr!( ctx) ;
783+
784+ match ext_type {
785+ // Previously rustls had support for this extension, but removed it as
786+ // the SCT-via-TLS-extension method was never widely deployed. Instead,
787+ // SCTs are delivered via an X.509v3 extension.
788+ //
789+ // If rustls retained that support, here is a sketch of how we could
790+ // proceed here:
791+ //
792+ // - store the callbacks and arguments, in a SCT-specific location,
793+ // inside the ctx's `sign::CertifiedKeySet`,
794+ // - when making a new `ServerConfig`, call `add_cb` to extract the
795+ // SCT extension body,
796+ // - decode the SCT extension body, and store the SCTs in our selected
797+ // `CertifiedKey::sct_list`,
798+ // - call `free_cb`.
799+ //
800+ // Instead, we say this call is successful, never call the callbacks,
801+ // and do not attach their data to an extension.
802+ EXTENSION_TYPE_SCT => C_INT_SUCCESS ,
803+ other => {
804+ log:: warn!( "SSL_CTX_add_server_custom_ext for 0x{other:x?} failed" ) ;
805+ 0
806+ }
807+ }
808+ }
809+ }
810+
811+ const EXTENSION_TYPE_SCT : u32 = 0x0012 ;
812+
813+ pub type custom_ext_add_cb = Option <
814+ unsafe extern "C" fn (
815+ s : * mut SSL ,
816+ ext_type : c_uint ,
817+ out : * mut * const c_uchar ,
818+ outlen : * mut usize ,
819+ al : * mut c_int ,
820+ add_arg : * mut c_void ,
821+ ) -> c_int ,
822+ > ;
823+
824+ pub type custom_ext_free_cb = Option <
825+ unsafe extern "C" fn ( s : * mut SSL , ext_type : c_uint , out : * const c_uchar , add_arg : * mut c_void ) ,
826+ > ;
827+
828+ pub type custom_ext_parse_cb = Option <
829+ unsafe extern "C" fn (
830+ s : * mut SSL ,
831+ ext_type : c_uint ,
832+ in_ : * const c_uchar ,
833+ inlen : usize ,
834+ al : * mut c_int ,
835+ parse_arg : * mut c_void ,
836+ ) -> c_int ,
837+ > ;
838+
772839impl Castable for SSL_CTX {
773840 type Ownership = OwnershipArc ;
774841 type RustType = NotThreadSafe < Self > ;
0 commit comments