1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read.R
\name{read_key}
\alias{read_key}
\alias{read_pubkey}
\alias{read_cert}
\alias{read_cert_bundle}
\alias{read_pem}
\title{Parsing keys and certificates}
\usage{
read_key(file, password = askpass, der = is.raw(file))
read_pubkey(file, der = is.raw(file))
read_cert(file, der = is.raw(file))
read_cert_bundle(file)
read_pem(file)
}
\arguments{
\item{file}{Either a path to a file, a connection, or literal data (a string for
pem/ssh format, or a raw vector in der format)}
\item{password}{A string or callback function to read protected keys}
\item{der}{set to \code{TRUE} if \code{file} is in binary DER format}
}
\value{
An object of class \code{cert}, \code{key} or \code{pubkey} which holds the data
in binary DER format and can be decomposed using \code{as.list}.
}
\description{
The \code{read_key} function (private keys) and \code{read_pubkey} (public keys)
support both SSH pubkey format and OpenSSL PEM format (base64 data with a \code{--BEGIN}
and \code{---END} header), and automatically convert where necessary. The functions assume
a single key per file except for \code{read_cert_bundle} which supports PEM files
with multiple certificates.
}
\details{
Most versions of OpenSSL support at least RSA, DSA and ECDSA keys. Certificates must
conform to the X509 standard.
The \code{password} argument is needed when reading keys that are protected with a
passphrase. It can either be a string containing the passphrase, or a custom callback
function that will be called by OpenSSL to read the passphrase. The function should
take one argument (a string with a message) and return a string. The default is to
use \code{readline} which will prompt the user in an interactive R session.
}
\examples{
\dontrun{# Read private key
key <- read_key("~/.ssh/id_rsa")
str(key)
# Read public key
pubkey <- read_pubkey("~/.ssh/id_rsa.pub")
str(pubkey)
# Read certificates
txt <- readLines("https://curl.haxx.se/ca/cacert.pem")
bundle <- read_cert_bundle(txt)
print(bundle)
}
}
\seealso{
\link{download_ssl_cert}
}
|