Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

write_pem

Export key or certificate


Description

The write_pem functions exports a key or certificate to the standard base64 PEM format. For private keys it is possible to set a password.

Usage

write_pem(x, path = NULL, password = NULL)

write_der(x, path = NULL)

write_pkcs1(x, path = NULL, password = NULL)

write_ssh(pubkey, path = NULL)

Arguments

x

a public/private key or certificate object

path

file to write to. If NULL it returns the output as a string.

password

string or callback function to set password (only applicable for private keys).

pubkey

a public key

Details

The pkcs1 format is a legacy format which only supports RSA keys and should not be used anymore. It is only provided for compatibility with some old SSH clients. Simply use write_pem to export keys and certs to the recommended format.

Examples

# Generate RSA keypair
key <- rsa_keygen()
pubkey <- key$pubkey

# Write to output formats
write_ssh(pubkey)
write_pem(pubkey)
write_pem(key, password = "super secret")

openssl

Toolkit for Encryption, Signatures and Certificates Based on OpenSSL

v1.4.4
MIT + file LICENSE
Authors
Jeroen Ooms [aut, cre] (<https://orcid.org/0000-0002-4035-0289>), Oliver Keyes [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.