| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/tls.R |
| 3 |
\name{write_cert} |
| 4 |
\alias{write_cert} |
| 5 |
\title{Generate Self-Signed Certificate and Key} |
| 6 |
\usage{ |
| 7 |
write_cert(cn = "127.0.0.1", valid = "20301231235959") |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{cn}{[default '127.0.0.1'] character issuer common name (CN) for the |
| 11 |
certificate. This can be either a hostname or an IP address, but must match |
| 12 |
the actual server URL as client authentication will depend on it.} |
| 13 |
|
| 14 |
\item{valid}{[default '20301231235959'] character 'not after' date-time in |
| 15 |
'yyyymmddhhmmss' format. The certificate is not valid after this time.} |
| 16 |
} |
| 17 |
\value{ |
| 18 |
A list of length 2, comprising \verb{$server} and \verb{$client}. These may be |
| 19 |
passed directly to the relevant argument of \code{\link[=tls_config]{tls_config()}}. |
| 20 |
} |
| 21 |
\description{ |
| 22 |
Generate self-signed x509 certificate and 4096 bit RSA private/public key |
| 23 |
pair for use with authenticated, encrypted TLS communications. |
| 24 |
} |
| 25 |
\details{ |
| 26 |
Note that it can take a second or two for the key and certificate to be |
| 27 |
generated. |
| 28 |
} |
| 29 |
\examples{ |
| 30 |
\dontshow{if (interactive()) withAutoprint(\{ # examplesIf} |
| 31 |
cert <- write_cert(cn = "127.0.0.1") |
| 32 |
ser <- tls_config(server = cert$server) |
| 33 |
cli <- tls_config(client = cert$client) |
| 34 |
|
| 35 |
s <- socket(listen = "tls+tcp://127.0.0.1:5555", tls = ser) |
| 36 |
s1 <- socket(dial = "tls+tcp://127.0.0.1:5555", tls = cli) |
| 37 |
|
| 38 |
# secure TLS connection established |
| 39 |
|
| 40 |
close(s1) |
| 41 |
close(s) |
| 42 |
|
| 43 |
cert |
| 44 |
\dontshow{\}) # examplesIf} |
| 45 |
} |