Subject: Re: [Netconf] zerotouch/16: How to encode a chain of certs?

From: Kent Watsen <[email-masked]>
Date: Fri, 12 Aug 2016 23:00:26 +0000

This issue was discussed in Berlin, but no decision was reached.   Here are my current thoughts:

1. use an ordered-by-user leaf-list of the X.509v3 structures encoded using DER

      I don’t think this is a good solution.  In fact, this is the current solution in
      the ietf-system-keychain module, for which there already is an open issue
      to replace it with better solution.  The reason this approach isn’t a
      good one is because tools generally use file formats that encode multiple
      certs into a single file (e.g., a .pem or .p12 file) - that is, one blob (not many)

2. concatenate multiple PEM together to encode a bundle of certs

     Encoding a single certificate into a PEM encoding is defined in RFC 7468,
     Section 8.    I am not able locate a reference concatenating multiple PEM
     encodings into a single message/string.   Without a normative reference,
     I’m hesitant to recommend going this route.

3. use a PKCS#12 structure from RFC 7292 to encode a bundle of certs

      PKCS#12 is a flexible format that can encode many objects, including
      what is calls a “CertBag” (i.e. a bag of certificates) defined in Section
      4.2.3.  OpenSSL can convert to and from a file containing multiple
      PEMs and a PKCS#12 as follows:

      #  cat rightful_owner/owner_cert.pem intermediate/ca_cert.pem > owner_bundle.pem
      #  openssl pkcs12 -export -in owner_bundle.pem -nokeys -out owner_bundle.p12
      #  openssl pkcs12 -in owner_bundle.p12 -nodes -out owner_bundle.pem.2
     #  diff owner_bundle.pem*  // there’s a small difference (comments only)

4. use a degenerate PKCS #7 structure from RFC 2315 to encode a bundle of certs

      While PKCS#7 is primarily used to encode signed data, there is a
      degenerate form of it that has no signatures, which according to
      Section 9 “provides a means for disseminating certificates”. OpenSSL
      can convert to and from a file containing multiple PEMs and a
      PKCS#7 as follows:

      # cat rightful_owner/owner_cert.pem intermediate/ca_cert.pem > owner_bundle.pem
      # openssl crl2pkcs7 -nocrl -certfile owner_bundle.pem -out owner_bundle.p7b
      # openssl pkcs7 -print_certs -in owner_bundle.p7b -out owner_bundle.pem.2
      # diff owner_bundle.pem*  // there’s a small difference (comments only)

5. use a ‘choice’ around all of the PEM and PKCS#7 and PKCS#12 formats

        choice {
          leaf certificate-pem {
            type binary;
          }
          leaf certificate-pk7 {
            type binary;
          }
          leaf certificate-p12 {
            type binary;
          }
        }

6. use a ‘format’ leaf to indicate if

        container certificate {
          leaf format {
            type enumeration {
              enum pem;
              enum pk7;
              enum p12;
            }
          }
          leaf data {
            type binary;
          }
        }

Recommendations:
  - If we have to pick just one, I’d ask security experts to pick between
    pk7 and p12.  Note: pk7 was a bit easier on the command line, in
    that it didn’t prompt for password.  Also, pk7 round-tripping
    stabilized faster.
  - If we’re okay with devices having to support all formats, then I
    think solution #6 is better than #5.

Does anyone else have any thoughts on this?

Kent

---

From: "Ersue, Mehmet (Nokia - DE/Munich)" <[email-masked]>
Date: Sat, 13 Aug 2016 12:57:40 +0000

Dear All,

technical spoken I’m in favor of supporting all formats with a ‘format’ leaf.

@All: Please comment on the proposal from Kent below.

Mehmet

From: Netconf [mailto:[email-masked]] On Behalf Of Kent Watsen
Sent: Saturday, August 13, 2016 1:00 AM
To: [email-masked]
Subject: Re: [Netconf] zerotouch/16: How to encode a chain of certs?

        choice {
          leaf certificate-pem {
            type binary;
          }
          leaf certificate-pk7 {
            type binary;
          }
          leaf certificate-p12 {
            type binary;
          }
        }

        container certificate {
          leaf format {
            type enumeration {
              enum pem;
              enum pk7;
              enum p12;
            }
          }
          leaf data {
            type binary;
          }
        }

Recommendations:

Kent