@@ -858,7 +858,11 @@ impl SslContextBuilder {
858858 init ( ) ;
859859 let ctx = cvt_p ( ffi:: SSL_CTX_new ( SslMethod :: tls_with_buffer ( ) . as_ptr ( ) ) ) ?;
860860
861- Ok ( SslContextBuilder :: from_ptr ( ctx, true ) )
861+ let mut builder = SslContextBuilder :: from_ptr ( ctx) ;
862+ builder. is_rpk = true ;
863+ builder. set_ex_data ( * RPK_FLAG_INDEX , true ) ;
864+
865+ Ok ( builder)
862866 }
863867 }
864868
@@ -897,48 +901,28 @@ impl SslContextBuilder {
897901 unsafe {
898902 init ( ) ;
899903 let ctx = cvt_p ( ffi:: SSL_CTX_new ( method. as_ptr ( ) ) ) ?;
900-
901- #[ cfg( feature = "rpk" ) ]
902- {
903- Ok ( SslContextBuilder :: from_ptr ( ctx, false ) )
904- }
905-
906- #[ cfg( not( feature = "rpk" ) ) ]
907- {
908- Ok ( SslContextBuilder :: from_ptr ( ctx) )
909- }
904+ Ok ( SslContextBuilder :: from_ptr ( ctx) )
910905 }
911906 }
912907
913908 /// Creates an `SslContextBuilder` from a pointer to a raw OpenSSL value.
914909 ///
915- /// # Safety
916- ///
917- /// The caller must ensure that the pointer is valid and uniquely owned by the builder.
918- #[ cfg( feature = "rpk" ) ]
919- pub unsafe fn from_ptr ( ctx : * mut ffi:: SSL_CTX , is_rpk : bool ) -> SslContextBuilder {
920- let ctx = SslContext :: from_ptr ( ctx) ;
921- let mut builder = SslContextBuilder {
922- ctx,
923- is_rpk,
924- has_shared_cert_store : false ,
925- } ;
926-
927- builder. set_ex_data ( * RPK_FLAG_INDEX , is_rpk) ;
928-
929- builder
930- }
931-
932- /// Creates an `SslContextBuilder` from a pointer to a raw OpenSSL value.
910+ #[ cfg_attr(
911+ feature = "rpk" ,
912+ doc = "Keeps previous RPK state. Use `new_rpk()` to enable RPK."
913+ ) ]
933914 ///
934915 /// # Safety
935916 ///
936917 /// The caller must ensure that the pointer is valid and uniquely owned by the builder.
937- # [ cfg ( not ( feature = "rpk" ) ) ]
918+ /// The context must own its cert store exclusively.
938919 pub unsafe fn from_ptr ( ctx : * mut ffi:: SSL_CTX ) -> SslContextBuilder {
920+ let ctx = SslContext :: from_ptr ( ctx) ;
939921 SslContextBuilder {
940- ctx : SslContext :: from_ptr ( ctx) ,
922+ #[ cfg( feature = "rpk" ) ]
923+ is_rpk : ctx. is_rpk ( ) ,
941924 has_shared_cert_store : false ,
925+ ctx,
942926 }
943927 }
944928
0 commit comments