if (FALSE) {
# Example 1: accept your local snakeoil https cert
mycert <- openssl::download_ssl_cert('localhost')[[1]]
# Setup the callback
h <- curl::new_handle(ssl_ctx_function = function(ssl_ctx){
ssl_ctx_add_cert_to_store(ssl_ctx, mycert)
}, verbose = TRUE, forbid_reuse = TRUE)
# Perform the request
req <- curl::curl_fetch_memory('https://localhost', handle = h)
# Example 2 using a custom verify function
verify_cb <- function(cert){
id <- cert$pubkey$fingerprint
cat("Server cert from:", as.character(id), "\n")
TRUE # always accept cert
}
h <- curl::new_handle(ssl_ctx_function = function(ssl_ctx){
ssl_ctx_set_verify_callback(ssl_ctx, verify_cb)
}, verbose = TRUE, forbid_reuse = TRUE)
# Perform the request
req <- curl::curl_fetch_memory('https://localhost', handle = h)
}
Run the code above in your browser using DataLab