<?xml version="1.0" encoding="US-ASCII"?>
<!-- this is version 5 of this xml2rfc template -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc2119 SYSTEM "https://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY rfc7468 SYSTEM "https://xml.resource.org/public/rfc/bibxml/reference.RFC.7468.xml">
<!ENTITY rfc8174 SYSTEM "https://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
<!ENTITY rfc8446 SYSTEM "https://xml.resource.org/public/rfc/bibxml/reference.RFC.8446.xml">
<!ENTITY rfc8446 SYSTEM "https://xml.resource.org/public/rfc/bibxml/reference.RFC.9460.xml">
<!ENTITY I-D.ietf-tls-esni SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-esni">
<!ENTITY I-D.ietf-tls-svcb-ech SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-tls-svcb-ech">

]>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="yes"?>
<?rfc strict="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<rfc category="std" docName="draft-farrell-tls-pemesni-12" ipr="trust200902" >
  <front>
    <title abbrev="PEM file format for ECH">PEM file format for ECH</title>

    <author fullname="Stephen Farrell" initials="S." surname="Farrell">
      <organization>Trinity College Dublin</organization>

      <address>
        <postal>
          <street/>

          <city>Dublin</city>

          <region/>

          <code>2</code>

          <country>Ireland</country>
        </postal>

        <phone>+353-1-896-2354</phone>

        <email>stephen.farrell@cs.tcd.ie</email>
      </address>
    </author>

    <date year="2026"/>

    <area>Security Area</area>

    <workgroup>Internet Engineering Task Force (IETF)</workgroup>

    <keyword>TLS</keyword>

    <keyword>ESNI</keyword>

    <abstract>
        <t>Encrypted ClientHello (ECH) key pairs need to be configured into TLS servers, which
            can be built using different TLS libraries, so there is a benefit and
            little cost in documenting a file format to use for these key pairs, similar to
            how RFC 7468 defines other PEM file formats.
            </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">

        <t>Encrypted ClientHello (ECH)
            <xref target="I-D.ietf-tls-esni"/> for TLS1.3 <xref target="RFC8446"/>
            defines a confidentiality mechanism for server names and other ClientHello
            content in TLS.
            That requires publication of an ECHConfigList data structure in an HTTPS or SVCB RR
            <xref target="RFC9460"/> in the DNS.
            An ECHConfigList can contain one or more ECHConfig values.
            An ECHConfig structure contains the public component of a key pair
            that will typically be periodically (re-)generated by some key manager
            for a TLS server.
            TLS servers then need to be configured to use these key pairs,
            and given that various TLS servers can be built with different
            TLS libraries, there is a benefit in having a standard format for
            ECH key pairs and configs, just as was done with <xref target="RFC7468"/>.
        </t>

      </section>

      <section title="Terminology">
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
        "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
        "OPTIONAL" in this document are to be interpreted as described in BCP
        14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only
        when, they appear in all capitals, as shown here.</t>
      </section>

      <section title="ECHConfig file">

          <t>A PEM ECH file contains zero or one private key and one encoded ECHConfigList.</t>

              <t>The public and private keys MUST both
              be PEM encoded. The file contains the concatenation of the PEM encoding
              of the private key (if present) followed by the PEM encoding of the public key(s) as
              an ECHConfigList.
              When a private key is present, the ECHConfigList MUST contain an ECHConfig that matches the private key.
                  The private key MUST be encoded as a PKCS#8 PrivateKey. The public
                  key(s) MUST be the base64 encoded form of an ECHConfigList value that
                  can be published in the DNS using an HTTPS RR as described in
              <xref target="I-D.ietf-tls-svcb-ech"/>.
              The string "ECHCONFIG" MUST be used in the PEM
                  file delimiter for the public key.</t>

              <t>Any content after the PEM encoded ECHConfigList SHOULD be ignored.</t>

              <t><xref target="sample"/> shows an example ECHConfig PEM File</t>

            <figure anchor="sample" title="Example ECHConfig PEM file" >
            <artwork><![CDATA[
-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VuBCIEICjd4yGRdsoP9gU7YT7My8DHx1Tjme8GYDXrOMCi8v1V
-----END PRIVATE KEY-----
-----BEGIN ECHCONFIG-----
AD7+DQA65wAgACA8wVN2BtscOl3vQheUzHeIkVmKIiydUhDCliA4iyQRCwAEAAEA
AQALZXhhbXBsZS5jb20AAA==
-----END ECHCONFIG-----
            ]]></artwork>
            </figure>

            <t>
                If the above ECHConfigList were published in the DNS for
                foo.example.com, then one could access that as shown
                in <xref target="dig"/>.
            </t>

            <figure anchor="dig" title="Use of dig to get the ECHConfigList from DNS" >
            <artwork><![CDATA[
$ dig +short HTTPS foo.example.com
1 . ech=AD7+DQA65wAgACA8wVN2BtscOl3vQheUzHeIkVmKIiydUhDCliA4iyQR
wAEAAEAAQALZXhhbXBsZS5jb20AAA==
            ]]></artwork>
            </figure>

            <t>
                TLS servers using this file format might configure
                multiple file names as part of their overall configuration,
                if, for example, only the ECHConfigList values
                from a subset of those files are to be used as the value for
                retry_configs in the ECH fallback scenario.
            </t>

            <t>
                The ECHConfigList in a PEM file might contain more than one
                ECHConfig if, for example, those ECHConfig values contain different
                extensions or different public_name values. If the
                ECHConfigList value is to be use as the retry_configs value,
                then that might contain different public keys. (Nonetheless,
                when a private key is present, that MUST match the public key
                from one of the ECHConfig values.)
            </t>



      </section>



    <section title="Security Considerations">
        <t>Storing cryptographic keys in files leaves them vulnerable should
            anyone get read access to the filesystem on which they are stored.
            The same protection mechanisms that would be used for a server's PEM
            encoded HTTPS certificate private key should be used for the PEM ECH
            configuration.
            </t>

            <t>
                The security considerations of <xref target="I-D.ietf-tls-svcb-ech"/>
                apply when retrieving an ECHConfigList from the DNS.
            </t>

            <t>
                For clarity, only the ECHConfigList is to be published
                in the DNS - the private key from an ECH PEM file MUST
                NOT be published in the DNS.
            </t>

    </section>

    <section title="Acknowledgements">
        <t>Thanks to Daniel McCarney, Jim Reid and Peter Yee for comments.</t>
    </section>

    <section title="IANA Considerations">
        <t>This document contains no IANA considerations.</t>
    </section>

  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='reference.RFC.2119'?>
      <?rfc include='reference.RFC.8174'?>
      <?rfc include='reference.RFC.8446'?>
      &I-D.ietf-tls-esni;

    </references>

    <references title="Informative References">
      <?rfc include='reference.RFC.7468'?>
      <?rfc include='reference.RFC.9460'?>
      &I-D.ietf-tls-svcb-ech;
    </references>

    <!--
    <section title="Change Log ">
      <t>[[RFC editor: please remove this before publication.]]</t>

      <t>From -00 to -01:
          <list style="symbols">
              <t>Re-structured a bit after re-reading rfc8615</t>
          </list>
      </t>
    </section>
    -->

    <section title="Changes">

      <t>From -11 to -12:
        <list style="symbols">
            <t>Changes resulting from IETF last call reviews.</t>
        </list>
      </t>
      <t>From -10 to -11:
        <list style="symbols">
            <t>Change to standards track as agreed with shepherd/AD.</t>
        </list>
      </t>
      <t>From -09 to -10:
        <list style="symbols">
            <t>Tweaks to fit being AD sponsored.</t>
        </list>
      </t>
      <t>From -08 to -09:
        <list style="symbols">
            <t>Minor clarification of encoding based on current
                OpenSSL ECH feature branch code.</t>
        </list>
      </t>
      <t>From -07 to -08:
        <list style="symbols">
            <t>Processed some github comments</t>
        </list>
      </t>
      <t>From -06 to -07:
        <list style="symbols">
            <t>Refresh due to expiry.</t>
        </list>
      </t>
      <t>From -05 to -06:
        <list style="symbols">
            <t>Refresh due to expiry.</t>
        </list>
      </t>
      <t>From -04 to -05:
        <list style="symbols">
            <t>Refresh due to expiry.</t>
        </list>
      </t>
      <t>From -03 to -04:
        <list style="symbols">
            <t>Refresh due to expiry.</t>
        </list>
      </t>
      <t>From -02 to -03:
        <list style="symbols">
            <t>Refresh due to expiry and not possible ISE destination</t>
        </list>
      </t>
      <t>From -01 to -02:
          <list style="symbols">
            <t>ECHO -> ECH</t>
          </list>
      </t>

      <t>From -00 to -01:
          <list style="symbols">
            <t>ESNI -> ECHO</t>
          </list>
      </t>

    </section>

  </back>
</rfc>
