Skip to content

Commit 07ee90c

Browse files
author
Jacob H. Haven
committed
Update README with diagrams and more detailed instructions
1 parent 75b8def commit 07ee90c

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

README.md

+149
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,129 @@
22
[![Build Status](https://travis-ci.org/cloudflare/gokeyless.png?branch=master)](https://travis-ci.org/cloudflare/gokeyless)
33
[![GoDoc](https://godoc.org/github.com/cloudflare/gokeyless?status.png)](https://godoc.org/github.com/cloudflare/gokeyless)
44

5+
56
## Keyless SSL implementation in Go
67
Go Keyless is an implementation CloudFlare's [Keyless SSL](https://blog.cloudflare.com/keyless-ssl-the-nitty-gritty-technical-details/) Protocol in Go. It is provided as
78
an upgrade to the previous [C implementation](https://github.com/cloudflare/keyless).
89

10+
## Protocol
11+
12+
The CloudFlare Keyless SSL client communicates to the server via a binary
13+
protocol over a mutually authenticated TLS 1.2 tunnel. Messages are in binary
14+
format and identified by a unique ID.
15+
16+
Messages consist of a fixed length header, and a variable length body. The
17+
body of the message consists of a sequence of items in TLV (tag, length,
18+
value) messages.
19+
20+
All messages with major version 1 will conform to the following
21+
format. The minor version is currently set to 0 and is reserved for
22+
communicating policy information.
23+
24+
Header:
25+
26+
0 - - 1 - - 2 - - 3 - - 4 - - - - 6 - - 7 - - 8
27+
| Maj | Min | Length | ID |
28+
| Body |
29+
| Body | <- 8 + Length
30+
31+
Item:
32+
33+
0 - - 1 - - 2 - - 3 - - 4 - - - - 6 - - 7 - - 8
34+
| Tag | Length | Data |
35+
| Data | <- 3 + Length
36+
37+
All numbers are in network byte order (big endian).
38+
39+
The following tag values are possible for items:
40+
41+
0x01 - Certificate Digest,
42+
0x02 - Server Name Indication,
43+
0x03 - Client's IP address,
44+
0x11 - Opcode,
45+
0x12 - Payload,
46+
47+
A requests contains a header and the following items:
48+
49+
0x01 - length: 32 bytes, data: SHA256 of RSA modulus
50+
0x02 - length: variable, data: SNI string
51+
0x03 - length: 4 or 16 bytes, data: IPv4/6 address
52+
0x11 - length: 1, data: opcode describing operation
53+
0x12 - length: variable, data: payload to sign or encrypt
54+
55+
The following opcodes are supported in the opcode item:
56+
57+
0x01 - operation: RSA decrypt payload
58+
0x02 - operation: RSA sign MD5SHA1
59+
0x03 - operation: RSA sign SHA1
60+
0x04 - operation: RSA sign SHA224
61+
0x05 - operation: RSA sign SHA256
62+
0x06 - operation: RSA sign SHA384
63+
0x07 - operation: RSA sign SHA512
64+
0x08 - operation: RSA raw decrypt payload
65+
0x12 - operation: ECDSA sign MD5SHA1
66+
0x13 - operation: ECDSA sign SHA1
67+
0x14 - operation: ECDSA sign SHA224
68+
0x15 - operation: ECDSA sign SHA256
69+
0x16 - operation: ECDSA sign SHA384
70+
0x17 - operation: ECDSA sign SHA512
71+
72+
Responses contain a header with a matching ID and only two items:
73+
74+
0x11 - length: 1, data: opcode describing operation status
75+
0x12 - length: variable, data: payload response
76+
77+
The following opcodes are supported in the opcode item:
78+
79+
0xF0 - operation: success, payload: modified payload
80+
0xFF - operation: RSA decrypt payload, payload:
81+
82+
On an error, these are the possible 1-byte payloads:
83+
84+
0x01 - cryptography failure
85+
0x02 - key not found - no matching certificate ID
86+
0x03 - read error - disk read failure
87+
0x04 - version mismatch - unsupported version incorrect
88+
0x05 - bad opcode - use of unknown opcode in request
89+
0x06 - unexpected opcode - use of response opcode in request
90+
0x07 - format error - malformed message
91+
0x08 - internal error - memory or other internal error
92+
93+
Defines and further details of the protocol can be found in [kssl.h](kssl.h)
94+
95+
![Image](docs/keyless_exchange_diagram.png)
96+
97+
## Key Management
98+
99+
The Keyless SSL server is a TLS server and therefore requires cryptographic
100+
keys. All requests are mutually authenticated, so both the client and the
101+
server need a TLS 1.2 compatible key pair. The client must present a client
102+
certificate that can be verified against the CA that the keyless server is
103+
configured to use.
104+
105+
The server will need a valid key and certificate pair in PEM format. The
106+
following options are required and take a path to these files. These two
107+
parameters set up the certificate (and associated private key) that will be
108+
presented by the server when a client connects.
109+
110+
--server-cert
111+
--server-key
112+
113+
The private keys that this server is able to use should be stored in
114+
PEM format in a directory denoted by the option:
115+
116+
--private-key-directory
117+
118+
In order to authenticate the client's certificate, a custom CA file is
119+
required. This CA file available is provided by CloudFlare and specified
120+
with:
121+
122+
--ca-file
123+
124+
# Deploying
125+
126+
## Installing
127+
9128
### Package Installation
10129
Instructions for installing Go Keyless from `.deb` and `.rpm` packages can be found at [https://pkg.cloudflare.com](https://pkg.cloudflare.com/).
11130

@@ -19,3 +138,33 @@ installation](http://golang.org/doc/install) and a properly set `GOPATH`.
19138
$ go get -u github.com/cloudflare/gokeyless/...
20139
$ go install github.com/cloudflare/gokeyless/cmd/gokeyless/...
21140
```
141+
142+
## Running
143+
144+
### Command-line Arguments
145+
146+
This is the keyserver for Keyless SSL. It consists of a single binary file
147+
`gokeyless` that has the following command-line options:
148+
149+
- `-port` (optional) The TCP port on which to listen for connections. These
150+
connections must be TLSv1.2. Defaults to 2407.
151+
- `-ca-file` Path to a PEM-encoded file containing the CA certificate(s) used to
152+
sign client certificates presented on connection.
153+
- `-cert`, `-key` Path to PEM-encoded files containing the
154+
certificate and private key that are used when a connection is made to the
155+
server. These must be signed by an authority that the client side recognizes.
156+
- `--private-key-directory` Path to a directory containing private keys which
157+
the keyserver provides decoding service against. The key files must end with
158+
".key" and be PEM-encoded. There should be no trailing / on the path.
159+
- `-loglevel` Level of logging as [defined here](https://godoc.org/github.com/cloudflare/cfssl/log#pkg-constants).
160+
- `--num-workers` (optional) The number of worker threads to start. Each
161+
worker thread will handle a single connection from a KSSL client. Defaults
162+
to 1.
163+
- `--pid-file` (optional) Path to a file into which the PID of the
164+
keyserver. This file is only written if the keyserver starts successfully.
165+
166+
## License
167+
168+
See the LICENSE file for details. Note: the license for this project is not
169+
'open source' as described in the [Open Source
170+
Definition](http://opensource.org/osd).

docs/keyless_exchange_diagram.png

78.7 KB
Loading

0 commit comments

Comments
 (0)