You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 KiB

Domain Names — Dehydrated TLS Certificates

IFA Proposal No. 3
Title: Domain Names — Dehydrated TLS Certificates
Status: Draft
Type: Standards Track
Created: 2016-06-12

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

This document is released into the public domain.

This document was authored by Jeremy Rand, with input from Ryan Castellucci and Hugo Landau.

Table of Contents

Introduction

This document extends the Domain Names specification, IFA-0001. It specifies an additional format of encoding the tls item type. This format is more suited for integrating tls item support into mainstream certificate trust stores, given the API limitations of those trust stores.

Extensible Alternate Encoding for tls Items

IFA-0001 specifies that a TLS item is a JSON list. This specification redefines TLS items to instead be a JSON object, of the form {encoding: data}. encoding can be "dane", in which case data is a JSON list in the form specified by IFA-0001. encoding can also be "d8", in which case data is in the form specified below. If multiple encoding keys exist for a single TLS item (e.g. both dane and d8 are available), then implementations MUST pick one of their choice. Implementations MAY assume that all encoding options for a TLS item are equivalent. If a TLS item that contains a JSON list instead of a JSON object is encountered, implementations MUST treat the list list as the JSON object {"dane": list}, which ensures backward-compatibility with IFA-0001.

Dehydrated tls Items

A dehydrated certificate in JSON format looks like:

{"d8":[1,"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEGm0zZlzrnwEYvub3BG3+VTKjvXWdMntoTanw3cwGAqcb0ALFrt5MdChT9t4josaefnGdVHa+ZBNmSEIaNZNhnw==",4944096,5154336,10,"MEUCIQCEkb4Q+AV8FsQgRoWSZ3S+1Ww/SySl4238SjTv5d/WAgIgX2rAhfCQ3gGG1Abhme8mDTG641vIYHJuz8d6m7IrgJo="]}

It is a JSON object of the form {"d8":list}, where list is a JSON list of 6 items.

  1. an integer representing a version number. Currently 1 is the only defined version. Dehydrated certificates with an unknown version MUST be ignored.
  2. a base64 string representing the public key. Typically an EC public key, not RSA, because EC is much more compact. The public key is not compressed, because compressed EC public keys are not widely supported by libraries (particularly the Golang standard library).
  3. an integer representing the "not before" part of the validity period, in units of 5 minutes. 5 minutes essentially divides the number by 300, which eliminates slightly more than 1 byte.
  4. an integer representing the "not after" part of the validity period, in units of 5 minutes. 5 minutes essentially divides the number by 300, which eliminates slightly more than 1 byte.
  5. an integer representing the signature algorithm. Typically ECDSA with SHA256.
  6. a base64 string representing the signature. Typically ECDSA with SHA256.

d8 is an abbreviation for how "dehydrate" is pronounced in English.

These 6 items are chosen for 3 reasons:

  1. A valid certificate can be rehydrated from these 6 items (plus a domain name). This means that TLS applications that require possessing a full certificate (not just a public key hash) in order to set up an override can be configured without out-of-band retrieval of a certificate.
  2. These items are much smaller (they are circa 255 bytes of JSON) than the rehydrated certificate would be, and therefore can comfortably fit into a datastore where storage is expensive (e.g. a Namecoin value).
  3. Rehydrated certificates are minimally trusted. For example, rehydrated certificates cannot be valid for other domain names or uses (via SAN, the CA flag, etc.) than the one which the user retrieving a TLSA record expects. As a result, these certificates can be added to a root CA trust store with minimal security implications.

To rehydrate into a full certificate, construct a self-signed certificate with the following fields:

  • NotBefore: based on dehydrated data, after converting units.
  • NotAfter: based on dehydrated data, after converting units.
  • KeyUsage: KeyUsageDigitalSignature
  • ExtKeyUsage: ExtKeyUsageServerAuth
  • BasicConstraintsValid: true
  • SignatureAlgorithm: based on dehydrated data
  • PublicKey: based on dehydrated data
  • Signature: based on dehydrated data
  • Subject CommonName: the .bit domain in use
  • Subject SerialNumber: "Namecoin TLS Certificate"
  • DNSNames: the .bit domain in use
  • SerialNumber: first 19 bytes of SHA256(SHA256(the .bit domain in use) | SHA256(PublicKey) | SHA256(big-endian int64 of NotBefore in units of 5 minutes) | SHA256(big-endian int64 of NotAfter in units of 5 minutes))

The certificate shown above in JSON, for the domain name www.veclabs.bit, looks like this:

$ cat cert.pem | openssl x509 -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            51:06:10:fe:12:53:81:e5:cd:ed:9a:38:7d:19:25:42:34:10:54
    Signature Algorithm: ecdsa-with-SHA256
        Issuer: CN=www.veclabs.bit/serialNumber=Namecoin TLS Certificate
        Validity
            Not Before: Jan  1 00:00:00 2017 GMT
            Not After : Jan  1 00:00:00 2019 GMT
        Subject: CN=www.veclabs.bit/serialNumber=Namecoin TLS Certificate
        Subject Public Key Info:
            Public Key Algorithm: id-ecPublicKey
                Public-Key: (256 bit)
                pub: 
                    04:1a:6d:33:66:5c:eb:9f:01:18:be:e6:f7:04:6d:
                    fe:55:32:a3:bd:75:9d:32:7b:68:4d:a9:f0:dd:cc:
                    06:02:a7:1b:d0:02:c5:ae:de:4c:74:28:53:f6:de:
                    23:a2:c6:9e:7e:71:9d:54:76:be:64:13:66:48:42:
                    1a:35:93:61:9f
                ASN1 OID: prime256v1
                NIST CURVE: P-256
        X509v3 extensions:
            X509v3 Key Usage: critical
                Digital Signature
            X509v3 Extended Key Usage: 
                TLS Web Server Authentication
            X509v3 Basic Constraints: critical
                CA:FALSE
            X509v3 Subject Alternative Name: 
                DNS:www.veclabs.bit
    Signature Algorithm: ecdsa-with-SHA256
         30:45:02:21:00:84:91:be:10:f8:05:7c:16:c4:20:46:85:92:
         67:74:be:d5:6c:3f:4b:24:a5:e3:6d:fc:4a:34:ef:e5:df:d6:
         02:02:20:5f:6a:c0:85:f0:90:de:01:86:d4:06:e1:99:ef:26:
         0d:31:ba:e3:5b:c8:60:72:6e:cf:c7:7a:9b:b2:2b:80:9a
-----BEGIN CERTIFICATE-----
MIIBzDCCAXKgAwIBAgITUQYQ/hJTgeXN7Zo4fRklQjQQVDAKBggqhkjOPQQDAjA9
MRgwFgYDVQQDEw93d3cudmVjbGFicy5iaXQxITAfBgNVBAUTGE5hbWVjb2luIFRM
UyBDZXJ0aWZpY2F0ZTAeFw0xNzAxMDEwMDAwMDBaFw0xOTAxMDEwMDAwMDBaMD0x
GDAWBgNVBAMTD3d3dy52ZWNsYWJzLmJpdDEhMB8GA1UEBRMYTmFtZWNvaW4gVExT
IENlcnRpZmljYXRlMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEGm0zZlzrnwEY
vub3BG3+VTKjvXWdMntoTanw3cwGAqcb0ALFrt5MdChT9t4josaefnGdVHa+ZBNm
SEIaNZNhn6NRME8wDgYDVR0PAQH/BAQDAgeAMBMGA1UdJQQMMAoGCCsGAQUFBwMB
MAwGA1UdEwEB/wQCMAAwGgYDVR0RBBMwEYIPd3d3LnZlY2xhYnMuYml0MAoGCCqG
SM49BAMCA0gAMEUCIQCEkb4Q+AV8FsQgRoWSZ3S+1Ww/SySl4238SjTv5d/WAgIg
X2rAhfCQ3gGG1Abhme8mDTG641vIYHJuz8d6m7IrgJo=
-----END CERTIFICATE-----

Note that a canonical implementation (in Go) of this scheme is being added to ncdns. Because the signatures will fail if the certificate is not constructed deterministically, the canonical implementation of certificate construction takes precedence over this spec and any examples. (Please report any inconsistencies.)

An IFA-0001-based JSON value which uses the above dehydrated certificate looks like this:

{
    "map":{
        "www":{
            "map":{
                "_tcp":{
                    "map":{
                        "_443":{
                            "tls":[
                                {
                                    "d8":[
                                        1,
                                        "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEGm0zZlzrnwEYvub3BG3+VTKjvXWdMntoTanw3cwGAqcb0ALFrt5MdChT9t4josaefnGdVHa+ZBNmSEIaNZNhnw==",
                                        4944096,
                                        5154336,
                                        10,
                                        "MEUCIQCEkb4Q+AV8FsQgRoWSZ3S+1Ww/SySl4238SjTv5d/WAgIgX2rAhfCQ3gGG1Abhme8mDTG641vIYHJuz8d6m7IrgJo="
                                    ]
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
}

Design Goals

The primary goal is to fit comfortably into a Namecoin value (which is limited to 520 bytes) when combined with IP addresses or other data. We believe that it achieves this. The goal is not to achieve optimal compression at this time. We expect to improve on the scalability of Namecoin values in the future, via proposals such as CBOR encoding, value compression, and segregated name values; improvements in dehydrated certificate encoding (e.g. compressed public keys and removing the overhead of base64 and decimal encoding) are fair game for those future efforts. We are choosing not to fully optimize at this time because we believe that the current proposal is currently sufficient, and future revisions to this spec are affected by ecosystem elements out of the scope of this proposal, including uncertainty about the above scalability improvements, and also including uncertainty about how TLS implementations may change their requirements in the future (for example, Mozilla's WebExtensions spec is still up in the air).

Changes to Processing Rules

There are no changes to item suppression or other processing rules.

Changes to Domain Name Owner Recommendations

Dehydrated tls items are more widely compatible with currently deployed TLS implementations, e.g. Google Chrome and Mozilla Firefox. However, because their encoding contains more data than a public key hash, dehydrated tls items will incur higher storage costs than the encoding specified in IFA-0001. Domain name owners are advised to consider the tradeoffs between compatibility and storage costs when choosing how to encode their tls items. It is our belief that, in most publicly deployed website configurations, the improved compatibility of dehydrated tls items makes their usage preferable, and that their increased storage costs are negligible in such configurations.

Changelog

  • 20170613: Revisions based on feedback.
  • 20160612: Initial revision.