Skip to main content

Module android

Module android 

Source
Available on Android only.
Expand description

On Android, initialization must be done before any verification is attempted.

Some manual setup is required outside of cargo to use this crate on Android. In order to use Android’s certificate verifier, the crate needs to call into the JVM. A small Kotlin component must be included in your app’s build to support rustls-platform-verifier.

See the crate’s Android section for more details.

§Examples

// A typical entrypoint signature for obtaining the necessary pointers
pub fn android_init(raw_env: *mut c_void, raw_context: *mut c_void) -> Result<(), jni::errors::Error> {
    let mut env = unsafe { JNIEnv::from_raw(raw_env as *mut jni::sys::JNIEnv).unwrap() };
    let context = unsafe { JObject::from_raw(raw_context as jni::sys::jobject) };
    rustls_platform_verifier::android::init_with_env(&mut env, context)?;
}

Traits§

Runtime
A layer to access the Android runtime which is hosting the current application process.

Functions§

init_with_env
Initialize given a typical Android NDK Env and JObject context.
init_with_refs
Initialize with references to the JVM, context, and class loader.
init_with_runtime
Initialize with a runtime that can dynamically serve references to the JVM, context, and class loader.