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