<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc compact="yes"?>
<?rfc toc="yes"?>

<rfc category="std" ipr="full3978" docName="rfc2538">

<front>

<title abbrev="Storing Certificates in the DNS">
Storing Certificates in the Domain Name System (DNS)
</title>

<author initials="S." surname="Josefsson" fullname="Simon Josefsson">
	<organization></organization>
	<address>
		<email>simon@josefsson.org</email>
	</address>
</author>
	
<date month="September" year="2004"/>

<abstract>

  <t>Cryptographic public key are frequently published and their
    authenticity demonstrated by certificates.  A CERT resource record
    (RR) is defined so that such certificates and related certificate
    revocation lists can be stored in the Domain Name System
    (DNS).</t>

</abstract>

</front>
	
<middle>

<section title="Introduction">

  <t>Public keys are frequently published in the form of a certificate
    and their authenticity is commonly demonstrated by certificates
    and related certificate revocation lists (CRLs).  A certificate is
    a binding, through a cryptographic digital signature, of a public
    key, a validity interval and/or conditions, and identity,
    authorization, or other information. A certificate revocation list
    is a list of certificates that are revoked, and incidental
    information, all signed by the signer (issuer) of the revoked
    certificates. Examples are X.509 certificates/CRLs in the X.500
    directory system or PGP certificates/revocations used by PGP
    software.</t>

  <t>Section 2 below specifies a CERT resource record (RR) for the
    storage of certificates in the Domain Name System.</t>

  <t>Section 3 discusses appropriate owner names for CERT RRs.</t>

  <t>Sections 4, 5, and 6 below cover performance, IANA, and security
    considerations, respectively.</t>

  <t>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 <xref
    target="RFC2119" />.</t>

</section>

<section title="The CERT Resource Record">

  <t>The CERT resource record (RR) has the structure given below.  Its
    RR type code is 37.</t>

  <figure>
    <artwork>
                    1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             type              |             key tag           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   algorithm   |                                               /
+---------------+            certificate or CRL                 /
/                                                               /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
    </artwork>
  </figure>

  <t>The type field is the certificate type as define in section 2.1
   below.</t>

  <t>The algorithm field has the same meaning as the algorithm field
    in KEY and SIG RRs <xref target="RFC2535" /> except that a zero
    algorithm field indicates the algorithm is unknown to a secure
    DNS, which may simply be the result of the algorithm not having
    been standardized for secure DNS.</t>

  <t>The key tag field is the 16 bit value computed for the key
   embedded in the certificate as specified in the DNSSEC Standard
   <xref target="RFC2535" />.  This field is used as an efficiency
   measure to pick which CERT RRs may be applicable to a particular
   key.  The key tag can be calculated for the key in question and
   then only CERT RRs with the same key tag need be examined. However,
   the key must always be transformed to the format it would have as
   the public key portion of a KEY RR before the key tag is computed.
   This is only possible if the key is applicable to an algorithm (and
   limits such as key size limits) defined for DNS security.  If it is
   not, the algorithm field MUST BE zero and the tag field is
   meaningless and SHOULD BE zero.</t>

  <section title="Certificate Type Values">

    <t>The following values are defined or reserved:</t>

    <figure>
      <artwork>
Value  Mnemonic  Certificate Type
-----  --------  ----------- ----
    0            reserved
    1   PKIX     X.509 as per PKIX
    2   SPKI     SPKI cert
    3   PGP      PGP cert
4-252            available for IANA assignment
  253   URI      URI private
  254   OID      OID private
255-65534        available for IANA assignment
65535            reserved
      </artwork>
    </figure>

    <t>The PKIX type is reserved to indicate an X.509 certificate
      conforming to the profile being defined by the IETF PKIX working
      group.  The certificate section will start with a one byte
      unsigned OID length and then an X.500 OID indicating the nature
      of the remainder of the certificate section (see 2.3 below).
      (NOTE: X.509 certificates do not include their X.500 directory
      type designating OID as a prefix.)</t>

    <t>The SPKI type is reserved to indicate a certificate formated as
      to be specified by the IETF SPKI working group.</t>

    <t>The PGP type indicates a Pretty Good Privacy certificate as
      described in <xref target="RFC2440" /> and its extensions and
      successors.</t>

    <t>The URI private type indicates a certificate format defined by
      an absolute URI.  The certificate portion of the CERT RR MUST
      begin with a null terminated URI <xref target="RFC2396" /> and
      the data after the null is the private format certificate
      itself.  The URI SHOULD be such that a retrieval from it will
      lead to documentation on the format of the certificate.
      Recognition of private certificate types need not be based on
      URI equality but can use various forms of pattern matching so
      that, for example, subtype or version information can also be
      encoded into the URI.</t>

    <t>The OID private type indicates a private format certificate
      specified by a an ISO OID prefix.  The certificate section will
      start with a one byte unsigned OID length and then a BER encoded
      OID indicating the nature of the remainder of the certificate
      section.  This can be an X.509 certificate format or some other
      format.  X.509 certificates that conform to the IETF PKIX
      profile SHOULD be indicated by the PKIX type, not the OID
      private type.  Recognition of private certificate types need not
      be based on OID equality but can use various forms of pattern
      matching such as OID prefix.</t>

  </section>

  <section title="Text Representation of CERT RRs">

    <t>The RDATA portion of a CERT RR has the type field as an
      unsigned integer or as a mnemonic symbol as listed in section
      2.1 above.</t>

    <t>The key tag field is represented as an unsigned integer.</t>

    <t>The algorithm field is represented as an unsigned integer or a
      mnemonic symbol as listed in <xref target="RFC2535" />.</t>

    <t>The certificate / CRL portion is represented in base 64 and may
      be divided up into any number of white space separated
      substrings, down to single base 64 digits, which are
      concatenated to obtain the full signature.  These substrings can
      span lines using the standard parenthesis.</t>

    <t>Note that the certificate / CRL portion may have internal
      sub-fields but these do not appear in the master file
      representation.  For example, with type 254, there will be an
      OID size, an OID, and then the certificate / CRL proper. But
      only a single logical base 64 string will appear in the text
      representation.</t>

  </section>

  <section title="X.509 OIDs">

    <t>OIDs have been defined in connection with the X.500 directory
      for user certificates, certification authority certificates,
      revocations of certification authority, and revocations of user
      certificates.  The following table lists the OIDs, their BER
      encoding, and their length prefixed hex format for use in CERT
      RRs:</t>

  <figure>
    <artwork>
    id-at-userCertificate
        = { joint-iso-ccitt(2) ds(5) at(4) 36 }
           == 0x 03 55 04 24
    id-at-cACertificate
        = { joint-iso-ccitt(2) ds(5) at(4) 37 }
           == 0x 03 55 04 25
    id-at-authorityRevocationList
        = { joint-iso-ccitt(2) ds(5) at(4) 38 }
           == 0x 03 55 04 26
    id-at-certificateRevocationList
        = { joint-iso-ccitt(2) ds(5) at(4) 39 }
           == 0x 03 55 04 27
    </artwork>
  </figure>

  </section>

</section>

<section title="Appropriate Owner Names for CERT RRs">

  <t>It is recommended that certificate CERT RRs be stored under a
    domain name related to their subject, i.e., the name of the entity
    intended to control the private key corresponding to the public
    key being certified.  It is recommended that certificate
    revocation list CERT RRs be stored under a domain name related to
    their issuer.</t>

  <t>Following some of the guidelines below may result in the use in
    DNS names of characters that require DNS quoting which is to use a
    backslash followed by the octal representation of the ASCII code
    for the character such as \000 for NULL.</t>

  <section title="X.509 CERT RR Names">

    <t>Some X.509 versions permit multiple names to be associated with
      subjects and issuers under "Subject Alternate Name" and "Issuer
      Alternate Name".  For example, x.509v3 has such Alternate Names
      with an ASN.1 specification as follows:</t>

    <figure>
      <artwork>
     GeneralName ::= CHOICE {
        otherName                  [0] INSTANCE OF OTHER-NAME,
        rfc822Name                 [1] IA5String,
        dNSName                    [2] IA5String,
        x400Address                [3] EXPLICIT OR-ADDRESS.&amp;Type,
        directoryName              [4] EXPLICIT Name,
        ediPartyName               [5] EDIPartyName,
        uniformResourceIdentifier  [6] IA5String,
        iPAddress                  [7] OCTET STRING,
        registeredID               [8] OBJECT IDENTIFIER
     }
      </artwork>
    </figure>

    <t>The recommended locations of CERT storage are as follows, in priority
      order:</t>

    <list style="numbers">

      <t>If a domain name is included in the identification in the
	certificate or CRL, that should be used.</t>

      <t>If a domain name is not included but an IP address is
	included, then the translation of that IP address into the
	appropriate inverse domain name should be used.</t>

      <t>If neither of the above it used but a URI containing a domain
	name is present, that domain name should be used.</t>

      <t>If none of the above is included but a character string name is
	included, then it should be treated as described for PGP names in
	3.2 below.</t>

      <t>If none of the above apply, then the distinguished name (DN)
	should be mapped into a domain name as specified in <xref
	target="RFC2247" />.</t>

    </list>

   <t>Example 1: Assume that an X.509v3 certificate is issued to
   /CN=John Doe/DC=Doe/DC=com/DC=xy/O=Doe Inc/C=XY/ with Subject
   Alternative names of (a) string "John (the Man) Doe", (b) domain
   name john- doe.com, and (c) uri
   &lt;https://www.secure.john-doe.com:8080/&gt;.  Then the storage
   locations recommended, in priority order, would be</t>

    <list style="numbers">

      <t>john-doe.com,</t>
      <t>www.secure.john-doe.com, and</t>
      <t>Doe.com.xy.</t>

    </list>

    <t>Example 2: Assume that an X.509v3 certificate is issued to
      /CN=James Hacker/L=Basingstoke/O=Widget Inc/C=GB/ with Subject
      Alternate names of (a) domain name widget.foo.example, (b) IPv4
      address 10.251.13.201, and (c) string "James Hacker
      &lt;hacker@mail.widget.foo.example&gt;".  Then the storage
      locations recommended, in priority order, would be</t>

    <list style="numbers">

      <t>widget.foo.example,</t>
      <t>201.13.251.10.in-addr.arpa, and</t>
      <t>hacker.mail.widget.foo.example.</t>

    </list>

  </section>

  <section title="PGP CERT RR Names">

    <t>PGP signed keys (certificates) use a general character string
      User ID <xref target="RFC2440" />.  However, it is recommended
      by PGP that such names include the RFC 822 email address of the
      party, as in "Leslie Example &lt;Leslie@host.example&gt;".  If
      such a format is used, the CERT should be under the standard
      translation of the email address into a domain name, which would
      be leslie.host.example in this case.  If no RFC 822 name can be
      extracted from the string name no specific domain name is
      recommended.</t>

  </section>

</section>

<section title="Performance Considerations">

  <t>Current Domain Name System (DNS) implementations are optimized for
   small transfers, typically not more than 512 bytes including
   overhead.  While larger transfers will perform correctly and work is
   underway to make larger transfers more efficient, it is still
   advisable at this time to make every reasonable effort to minimize
   the size of certificates stored within the DNS.  Steps that can be
   taken may include using the fewest possible optional or extensions
   fields and using short field values for variable length fields that
    must be included.</t>

</section>

<section title="IANA Considerations">

  <t>Certificate types 0x0000 through 0x00FF and 0xFF00 through 0xFFFF
    can only be assigned by an IETF standards action <xref
    target="RFC2434" /> (and this document assigns 0x0001 through
    0x0003 and 0x00FD and 0x00FE).  Certificate types 0x0100 through
    0xFEFF are assigned through IETF Consensus <xref target="RFC2434"
    /> based on RFC documentation of the certificate type.  The
    availability of private types under 0x00FD and 0x00FE should
    satisfy most requirements for proprietary or private types.</t>

</section>

<section title="Security Considerations">

  <t>By definition, certificates contain their own authenticating
    signature.  Thus it is reasonable to store certificates in
    non-secure DNS zones or to retrieve certificates from DNS with DNS
    security checking not implemented or deferred for efficiency.  The
    results MAY be trusted if the certificate chain is verified back
    to a known trusted key and this conforms with the user's security
    policy.</t>

  <t>Alternatively, if certificates are retrieved from a secure DNS
    zone with DNS security checking enabled and are verified by DNS
    security, the key within the retrieved certificate MAY be trusted
    without verifying the certificate chain if this conforms with the
    user's security policy.</t>

  <t>CERT RRs are not used in connection with securing the DNS
    security additions so there are no security considerations related
    to CERT RRs and securing the DNS itself.</t>

</section>

</middle>

<back>

<references title="References">

  <?rfc include="reference.RFC.1034.xml"?>
  <?rfc include="reference.RFC.1035.xml"?>
  <?rfc include="reference.RFC.2119.xml"?>
  <?rfc include="reference.RFC.2247.xml"?>
  <?rfc include="reference.RFC.2396.xml"?>
  <?rfc include="reference.RFC.2440.xml"?>
  <?rfc include="reference.RFC.2434.xml"?>
  <?rfc include="reference.RFC.2535.xml"?>
  <?rfc include="reference.RFC.2459.xml"?>

</references>

</back>

</rfc>
