ctz / rustls
- понедельник, 11 июля 2016 г. в 03:12:53
Rust
Embryonic Rust TLS library
Rustls is a new, modern TLS library written in Rust. It's pronounced 'rustles'. It uses ring for cryptography and libwebpki for certificate verification.
Rustls is currently in development and hence unstable.
Lives here: https://jbp.io/rustls/rustls/
Rustls is a TLS library that aims to provide a good level of cryptographic security, requires no configuration to achieve that security, and provides no unsafe features or obsolete cryptography.
The following things are broken, obsolete, badly designed, underspecified, dangerous and/or insane. Rustls does not support:
There are plenty of other libraries that provide these features should you need them.
There are two example programs which use mio to do asynchronous IO.
The client example program is named tlsclient
. The interface looks like:
Connects to the TLS server at hostname:PORT. The default PORT
is 443. By default, this reads a request from stdin (to EOF)
before making the connection. --http replaces this with a
basic HTTP GET request for /.
If --cafile is not supplied, CA certificates are read from
`/etc/ssl/certs/ca-certificates.crt'.
Usage:
tlsclient [--verbose] [-p PORT] [--http] [--mtu MTU] [--cache CACHE]
[--cafile CAFILE] [--suite SUITE...] [--proto PROTOCOL...] <hostname>
tlsclient --version
tlsclient --help
Options:
-p, --port PORT Connect to PORT. Default is 443.
--http Send a basic HTTP GET request for /.
--cafile CAFILE Read root certificates from CAFILE.
--suite SUITE Disable default cipher suite list, and use
SUITE instead.
--proto PROTOCOL Send ALPN extension containing PROTOCOL.
--cache CACHE Save session cache to file CACHE.
--verbose Emit log output.
--mtu MTU Limit outgoing messages to MTU bytes.
--version Show tool version.
--help Show this screen.
Some sample runs:
$ ./tlsclient --http mozilla-modern.badssl.com
HTTP/1.1 200 OK
Server: nginx/1.6.2 (Ubuntu)
Date: Wed, 01 Jun 2016 18:44:00 GMT
Content-Type: text/html
Content-Length: 644
(...)
or
$ ./target/debug/examples/tlsclient --http expired.badssl.com
TLS error: WebPKIError(CertExpired)
Connection closed
The server example program is named tlsserver
. The interface looks like:
Runs a TLS server on :PORT. The default PORT is 443.
`echo' mode means the server echoes received data on each connection.
`http' mode means the server blindly sends a HTTP response on each connection.
`forward' means the server forwards plaintext to a connection made to
localhost:fport.
`--certs' names the full certificate chain, `--key' provides the RSA private
key.
Usage:
tlsserver --certs CERTFILE --key KEYFILE [--verbose] [-p PORT] [--suite SUITE...] [--proto PROTOCOL...] echo
tlsserver --certs CERTFILE --key KEYFILE [--verbose] [-p PORT] [--suite SUITE...] [--proto PROTOCOL...] http
tlsserver --certs CERTFILE --key KEYFILE [--verbose] [-p PORT] [--suite SUITE...] [--proto PROTOCOL...] forward <fport>
tlsserver --version
tlsserver --help
Options:
-p, --port PORT Listen on PORT. Default is 443.
--certs CERTFILE Read server certificates from CERTFILE.
This should contain PEM-format certificates
in the right order (the first certificate should
certify KEYFILE, the last should be a root CA).
--key KEYFILE Read private key from KEYFILE. This should be a RSA private key,
in PEM format.
--suite SUITE Disable default cipher suite list, and use
SUITE instead.
--proto PROTOCOL Negotiate PROTOCOL using ALPN.
--verbose Emit log output.
--version Show tool version.
--help Show this screen.
Here's a sample run; we start a TLS echo server, then connect to it with openssl and tlsclient:
$ ./tlsserver --certs test-ca/rsa/end.fullchain --key test-ca/rsa/end.rsa -p 8443 echo &
$ echo hello world | openssl s_client -ign_eof -quiet -connect localhost:8443
depth=2 CN = ponytown RSA CA
verify error:num=19:self signed certificate in certificate chain
hello world
^C
$ echo hello world | ./tlsclient --cafile test-ca/rsa/ca.cert -p 8443 localhost
hello world
^C
Rustls is distributed under the following three licenses:
These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC respectively. You may use this software under the terms of any of these licenses, at your option.