<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='./rfc2629.xslt' ?>

<?rfc toc="yes"?>
<?rfc tocdepth='5'?>
<?rfc symrefs="no"?>
<?rfc compact="no" ?>
<?rfc sortrefs="yes" ?>
<?rfc strict="yes" ?>
<?rfc linkmailto="yes" ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" >

<?xml-stylesheet type='text/xsl' href='./rfc2629.xslt' ?>

<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc compact="no" ?>
<?rfc subcompact="yes" ?>
<?rfc sortrefs="yes" ?>
<rfc ipr="trust200902" docName="draft-gutmann-scep-03.txt" category="std">

  <!-- ======================================================================== -->
  <front>
    <title abbrev="SCEP">Simple Certificate Enrolment Protocol</title>
    <author initials="P." surname="Gutmann" fullname="Peter Gutmann">
      <organization abbrev="University of Auckland">University of Auckland</organization>
      <address>
        <postal>
          <street>Department of Computer Science</street>
          <city>Auckland</city>
          <country>New Zealand</country>
        </postal>
        <email>pgut001@cs.auckland.ac.nz</email>
      </address>
    </author>
    <author initials="M." surname="Pritikin" fullname="Max Pritikin">
      <organization abbrev="Cisco">Cisco Systems, Inc</organization>
    </author>
    <date year="2016"/>
    <area>Security Area</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>

This document specifies the Simple Certificate Enrolment Protocol (SCEP), a
Public Key Infrastructure (PKI) communication protocol which leverages
existing technology by using CMS (formerly known as PKCS #7) and PKCS #10 over
HTTP.  SCEP is the evolution of the enrolment protocol sponsored by Cisco
Systems, which now enjoys wide support in both client and server
implementations, as well as being relied upon by numerous other industry
standards that work with certificates.

      </t>
    </abstract>
  </front>
  <!-- ======================================================================== -->
  <middle>

    <!-- ====================================================================== -->
    <section anchor="introduction" title="Introduction">
      <t>

Public key technology is widely available and increasingly widely deployed.
X.509 certificates serve as the basis for several standards-based security
protocols in the IETF, such as <xref target="TLS">TLS</xref>, <xref
target="SMIME">S/MIME</xref>, and and <xref target="IKEv2">IKE/IPsec</xref>.
When an X.509 certificate is issued by other than the certificate subject (a
self-issued certificate), there typically is a need for a certificate
management protocol. Such a protocol enables a PKI client to request a
certificate, certificate renewal, or certificate update from a Certification
Authority (CA).

      </t>
      <t>

This specification defines a protocol, Simple Certificate Enrolment Protocol
(SCEP), for certificate management and certificate and CRL queries in a closed
environment.  While widely deployed, this protocol omits some certificate
management features, e.g. certificate revocation transactions, which can
significantly enhance the security achieved in a PKI.  The IETF protocol suite
currently includes two further certificate management protocols with more
comprehensive functionality: <xref target="CMP">Certificate Management
Protocol (CMP)</xref> and <xref target="CMC">Certificate Management over CMS
(CMC)</xref>.  Environments that do not require interoperability with SCEP
implementations MAY consider using the above-mentioned certificate management
protocols, however anyone considering this step should be aware that the high
level of complexity of these two protocols has resulted in serious
interoperability problems and corresponding lack of industry support.  SCEP's
simplicity, while being a drawback in terms of its limited functionality, also
makes deployment relatively straightforward, so that it enjoys widespread
industry support and ready interoperability across a wide range of platforms.
While implementers are encouraged to investigate one of the more comprehensive
alternative certificate management protocols in addition to the protocol
defined in this specification, anyone wishing to deploy them should proceed
with caution, and consider support and interoperability issues before
committing to their use.

      </t>
      <t>

The protocol supports the following general operations:

      </t>
      <t>

      <list style="symbols">

		<t>CA public key distribution.</t>

		<t>Certificate enrolment.</t>

		<t>Certificate renewal/update.</t>

		<t>Certificate query.</t>

		<t>CRL query.</t>

      </list>

      </t>
      <t>

SCEP makes extensive use of <xref target="CMS">CMS</xref> and <xref
target="PKCS10">PKCS #10</xref>.

      </t>
      <section anchor="mustshouldmay" title="Conventions Used in This Document">
        <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>
    <!-- ====================================================================== -->
    <section anchor="overview" title="SCEP Overview">
      <t>

This section provides a high level overview of the functionality of SCEP.

      </t>
      <section anchor="overview-entities" title="SCEP Entities">
        <t>

The entity types defined in SCEP are

        </t>
        <t>

        <list style="symbols">

		  <t>The Requester, or client (<xref
		     target="overview-requester"/>).</t>

		  <t>The Server, a Certification Authority (CA) (<xref
			 target="overview-ca"/>).</t>

        </list>

        </t>
        <section anchor="overview-requester" title="Requester">
          <t>

The requester is sometimes called a "client" in this document.  It is the
client of the SCEP exchange.

          </t>
          <t>

Before a requester can start a PKI transaction, it MUST have at least one
appropriate key pair for use when signing the SCEP pkiMessage (<xref
target="pkiMessage"/>).

          </t>
          <t>

The message types, being based on <xref target="CMS">CMS</xref> and <xref
target="PKCS10">PKCS #10</xref>, fully support algorithm agility but the
requester has to use a key type that is supported by the server.
Specifically, they must employ a PKC algorithm capable of both encryption and
signing.  RSA is the only widely-used algorithm that has these properties.

          </t>
          <t>

A requester MUST have the following information locally configured:

          </t>
          <t>

          <list style="numbers">

			<t>The Certification Authority IP address or fully qualified
			domain name.</t>

			<t>The Certification Authority HTTP CGI script path (this usually
			has a default value, see <xref target="HTTP-GET-POST"/>).</t>

			<t>The identifying information that is used for authentication of
			the Certification Authority in <xref target="GetCACert-resp"/>,
			typically a certificate fingerprint.  This information MAY be
			obtained from the user, or presented to the end user for manual
			authorization during the protocol exchange (e.g. the user
			indicates acceptance of a fingerprint via a user-interface
			element).</t>

          </list>

          </t>
          <t>

The requester MAY maintain multiple independent configurations appropriate for
multiple Certification Authorities.  Doing so does not effect the protocol
operation and is not in scope of this document.

          </t>
		</section>
        <section anchor="overview-ca" title="Certification Authority">
          <t>

A SCEP Certification Authority (CA) is the entity that signs client
certificates.  A certification authority MAY enforce any arbitrary policies
and apply them to certification requests.  The certification authority MAY
reject any request. If the client has already been issued a certificate for
this keypair the server MAY return the previously created certificate.  The
requester MUST NOT assume any of the fields in the certification request,
except for the public key, will be the same in the certificate issued.

          </t>
          <t>

The certification authority MAY include a cRLDistributionPoint extension in
every certificate it issues, make CRLs available via <xref
target="HTTP-certstore">HTTP</xref> or LDAP, or answer CRL queries itself.  In
the latter case it SHOULD be online at all times.

          </t>
          <t>

Since the client is expected to perform encryption and signature verification
using the CA certificate, the keyUsage extension in the CA certificate MUST
indicate that it is valid for digitalSignature and keyEncipherment use
alongside the usual CA usages of keyCertSign and/or cRLSign.

          </t>
          <t>

If a client times out from polling for a pending request it can resynchronize
by reissuing the original request with the original subject name, key, and
transactionID.  The CA SHOULD return the status of the original transaction,
including the certificate if it was granted.

          </t>
		</section>
        <section anchor="overview-cert-dist" title="CA Certificate Distribution">
      	  <t>

If the CA certificate(s) have not previously been acquired by the requester in
some other means, the requester MUST retrieve the CA certificate(s) before any
PKI operation (<xref target="message-obj"/>) can be started.

          </t>
          <t>

Since no public key has yet been exchanged between the requester and the CA,
the messages cannot be secured using <xref target="CMS">CMS</xref>, and the
data is instead transferred in the clear.

          </t>
          <t>

If an intermediate CA is in use, a certificates-only <xref target="CMS">
CMS</xref> Signed-Data message with a certificate chain consisting of all CA
certificates is returned.  Otherwise the CA certificate itself is returned.
The transport protocol (<xref target="transport"/>) MUST indicate which one is
returned.

          </t>
          <t>

The SCEP server CA certificate MAY be provided out-of-band to the SCEP
requester.  Alternatively, the CA certificate fingerprint MAY be used to
authenticate a CA Certificate distributed by the GetCACert response (<xref
target="GetCACert"/>) or via <xref target="HTTP-certstore">HTTP</xref>.  The
fingerprint is created by calculating a SHA-1, SHA-256, or SHA-512 hash over
the whole CA certificate.

          </t>
          <t>

After the requester gets the CA certificate, it SHOULD authenticate the
certificate by comparing its fingerprint with the locally configured, out-of-
band distributed, identifying information.  Intermediate CA certificates, if
any, are signed by a higher-level CA so there is no need to authenticate them
against the out-of-band data.  Clients SHOULD verify intermediate-level CA
certificate signatures using the issuing CA's certificate before use during
protocol exchanges.

          </t>
          <t>

Because a long time can pass between queries from a requester to a CA and
because intermediate CA certificates can change over time, it is recommended
that a requester not store intermediate CA certificates.  Instead, the
requester SHOULD retrieve the CA certificates before each operation.

          </t>
	    </section>
	  </section>
      <section anchor="overview-req-auth" title="Requester authentication">
        <t>

As with every protocol that uses public-key cryptography, the association
between the public keys used in the protocol and the identities with which
they are associated must be authenticated in a cryptographically secure
manner.  This requirement is needed to prevent a man-in-the-middle (MITM)
attack, in which an adversary can manipulate the data as it travels between
the protocol participants and subvert the security of the protocol.

        </t>
        <t>

The communication between the requester and the certification authority are
secured using SCEP Secure Message Objects (<xref target="message-obj"/>) which
specifies how <xref target="CMS">CMS</xref> is used to encrypt and sign the
data.  In order to perform the signing operation the client uses an
appropriate local certificate:

        </t>
        <t>

        <list style="numbers">

		  <t>If the requester does not have an appropriate existing
		  certificate then a locally generated self-signed certificate MUST be
		  used.  The self-signed certificate SHOULD use the same subject name
		  as in the PKCS #10 request.  In this case the messageType is
		  PKCS10Req (see <xref target="messageType"/>).</t>

		  <t>If the requesting system already has a certificate issued by the
		  SCEP server, and the server supports renewal (see <xref
		  target="overview-cert-enrol"/>), that certificate SHOULD be used.  In this
		  case the messageType is RenewalReq (see <xref
		  target="messageType"/>).</t>

		  <t>If the requesting system has no certificate issued by the new CA,
		  but has credentials from an alternate CA the certificate issued by
		  the alternate CA MAY be used.  Policy settings on the new CA will
		  determine if the request can be accepted or not. This is useful when
		  enrolling with a new administrative domain using a certificate from
		  the old domain as credentials.  In this case the messageType is
		  UpdateReq (see <xref target="messageType"/>).</t>

        </list>

        </t>
        <t>

Note that although the above text describes three different types of
operations, in practice most implementations always apply the first one even
if an existing certificate already exists.  For this reason support for the
first case is mandatory while support for the latter two are optional (see
<xref target="MTI"/>).

        </t>
        <t>

During the certificate enrolment process, the requester MUST use the selected
certificate's key when signing the <xref target="CMS">CMS</xref> envelope (see
<xref target="message-obj"/>).  The server's CertResp then uses the same
certificate's public key when encrypting the response (see <xref
target="CertRep"/>).

        </t>

<figure><artwork><![CDATA[
    [Question: This is another area where the semantics were never
     defined, what happens during a renewal or update?  For an
     enrolment the signing cert contains the key that's also in the
     request, but what about for a renewal or update where they're
     quite probably different keys?  Should the envelope be
     encrypted to the key in the request or the signing key?].
]]></artwork></figure>

        <t>

When the certification authority creates the <xref target="CMS">CMS</xref>
envelope containing the issued certificate, it SHOULD use the public key and
identifying information conveyed in the above included certificate.  This will
inform the end entity of which private key is needed to open the envelope.

        </t>
	  </section>
      <section anchor="overview-enrol-auth" title="Enrolment authorization">
        <t>

<xref target="PKCS10">PKCS #10</xref> specifies a <xref target="PKCS9">PKCS
#9</xref> challengePassword attribute to be sent as part of the enrolment
request.  When utilizing the challengePassword, the server distributes a
shared secret to the requester which will uniquely associate the enrolment
request with the requester.

        </t>
        <t>

Inclusion of the challengePassword by the SCEP client is OPTIONAL and allows
for unauthenticated authorization of enrolment requests (which, however,
requires manual approval of each certificate issue, see below), or for renewal
or update requests which are authenticated by being signed with an existing
certificate.  The <xref target="CMS">CMS</xref> envelope protects the privacy
of the challengePassword.

        </t>
        <t>

A client that is performing certificate renewal or update as per <xref
target="overview-cert-enrol"/> SHOULD omit the challengePassword but MAY send
the originally distributed password in the challengePassword attribute.  In
the former case the SCEP CA MUST authenticate the request based on the
certificate used to sign the renewal or update request.  In the latter case
the SCEP CA MAY use either the challengePassword or the previously issued
certificate (or both), depending on CA policy, to authenticate the request.
The SCEP server MUST NOT attempt to authenticate a client based on a
self-signed certificate unless it has been verified through out-of-band means
such as a certificate fingerprint.

        </t>
        <t>

To perform the authorization in manual mode the requester's messages are
placed in the PENDING state until the CA operator authorizes or rejects them.
Manual authorization is used when the client has only a self-signed
certificate that hasn't been previously authenticated by the CA and/or a
challengePassword is not available.  The SCEP server MAY either reject
unauthorized certification requests or mark them for manual authorization
according to CA policy.

        </t>
	  </section>
      <section anchor="overview-cert-enrol" title="Certificate Enrolment/Renewal/Update">
        <t>

A requester starts an enrolment (<xref target="PKCSReq"/>) transaction by
creating a certificate request using <xref target="PKCS10">PKCS #10</xref> and
sends it to the CA enveloped using <xref target="CMS">CMS</xref> (<xref
target="message-obj"/>).

	    </t>
	    <t>

If the CA supports certificate renewal or update then a new certificate with
new validity dates can be issued, even though the old one is still valid, if
the CA policy permits.  The server MAY automatically revoke the old client
certificate.  To renew or update an existing certificate, the client uses the
RenewalReq or UpdateReq message (see <xref target="pkiMessage-types"/>) and
signs it with the existing client certificate.  The client SHOULD use a new
keypair when requesting a new certificate, but MAY request a new certicate
using the old keypair.

        </t>
        <t>

If the CA returns a CertRep (<xref target="CertRep"/>) message with status set
to PENDING, the requester enters into polling mode by periodically sending a
CertPoll (<xref target="CertPoll"/>) PKI message to the CA, until the CA
operator completes the manual authentication (approving or denying the
request).

        </t>
        <t>

In general, the requester will send a single PKCSReq/RenewalReq/UpdateReq
(<xref target="PKCSReq"/>) message, followed by 0 or more CertPoll (<xref
target="CertPoll"/>) messages, if polling mode is entered.

        </t>
        <t>

In general, the CA will send 0 or more CertRep (<xref target="CertRep"/>)
messages with status set to PENDING, followed by a single CertRep (<xref
target="CertRep"/>) with status set to either SUCCESS or FAILURE.

        </t>
		<section anchor="overview-client-state" title="Client State Transitions">
		  <t>

The requester state transitions during enrolment operation are indicated in
<xref target="state-diagram"/>.

		  </t>
		  <figure anchor="state-diagram" title="State Transition Diagram">
			<artwork><![CDATA[

                         CertPoll
                        +----<---+
                        |        | CertRep(PENDING),
                        |        | CertPoll send-timeout,
                        |        | new-poll timer
                        |        |
[CERT-NONEXISTENT] -----+---> [CERT-REQ-PENDING]      [CERT-ISSUED]
      ^             PKCSReq      |          |               ^
      |           RenewalReq     |          |               |
      |            UpdateReq     |          +---------------+
      |                          |           CertRep(SUCCESS)
      +--------------------------+
      CertRep(FAILURE),
      PKCS/Update/RenewalReq send-timeout,
      max-time/max-polls exceeded

			]]></artwork>
		  </figure>
		  <t>

The certificate issue process starts at the state CERT-NONEXISTENT.

		  </t>
		  <t>

Sending a PKCSReq/RenewalReq/UpdateReq message changes the state to
CERT-REQ-PENDING.  If there is no response, or sending is not possible, the
state reverts back to CERT-NONEXISTENT.

		  </t>
		  <t>

Receiving a CertRep message with pkiStatus set to SUCCESS changes the state to
CERT-ISSUED.

		  </t>
		  <t>

Receiving a CertRep message with pkiStatus set to FAILURE changes the state to
CERT-NONEXISTENT.

		  </t>
		  <t>

If the server sends back a CertRep message with pkiStatus set to PENDING, the
requester will keep polling by sending a CertPoll message to the server, until
either a CertRep message with status set to SUCCESS or FAILURE is received, or
the maximum number of polls has been exceeded.

		  </t>
		  <t>

If the maximum number of polls has been exceeded or a CertRep message with
pkiStatus set to FAILURE is received while in the CERT-REQ-PENDING state, the
end entity will transition to the CERT-NONEXISTENT state, and the SCEP client
can eventually initiate another enrolment request.  It is important to note
that, as long as the requester does not change its subject name or keys, the
same transactionID may be used in the "new" transaction.  This is important
because based on this transactionID, the certification authority can recognize
this as an existing transaction instead of a new one.

		  </t>
		  <figure>
		  	<preamble>A successful transaction in automatic mode:</preamble>
			<artwork><![CDATA[

    REQUESTER                           CA SERVER

PKCSReq: PKI cert. enrolment msg
--------------------------------> CertRep: pkiStatus = SUCCESS
                                  certificate attached
                                  <------------------------------
Receive issued certificate.

			]]></artwork>
		  </figure>

		  <figure>
		  	<preamble>A successful transaction in manual mode:</preamble>
			<artwork><![CDATA[

    REQUESTER                           CA SERVER

PKCSReq: PKI cert. enrolment msg
--------------------------------> CertRep: pkiStatus = PENDING
                                  <------------------------------
CertPoll: polling msg
--------------------------------> CertRep: pkiStatus = PENDING
                                  <------------------------------
................ <manual identity authentication> ...............

CertPoll: polling msg
--------------------------------> CertRep: pkiStatus = SUCCESS
                                  certificate attached
                                  <------------------------------
Receive issued certificate.

			]]></artwork>
		  </figure>
		</section>
	  </section>
      <section anchor="overview-cert-access" title="Certificate Access">
        <t>

A certificate query message is defined for clients to retrieve a copy of their
own certificate from the CA.  It allows clients that do not store their
certificates locally to obtain a copy when needed.  This functionality is not
intended to provide a general purpose certificate store access service, which
may be achieved via <xref target="HTTP-certstore">HTTP</xref> or LDAP.

        </t>
        <t>

To query a certificate from the certification authority, a requester sends a
request consisting of the certificate's issuer name and serial number.  This
assumes that the requester has saved the issuer name and the serial number of
the issued certificate from the previous enrolment transaction.  The
transaction to query a certificate consists of one GetCert (<xref
target="GetCert"/>) message and one CertRep (<xref target="CertRep"/>)
message, as shown below.

        </t>
		<figure>
		  <artwork><![CDATA[

   REQUESTER                           CA SERVER

GetCert: PKI certificate query msg
-------------------------------> CertRep:  pkiStatus = SUCCESS
                                 certificate attached
                                 <-----------------------------
Receive the certificate.

		  ]]></artwork>
		</figure>
	  </section>
      <section anchor="overview-CRL-access" title="CRL Access">
        <t>

SCEP clients MAY request a CRL via one of three methods:

        </t>
        <t>

        <list style="numbers">

		  <t>If the CA supports <xref target="PKIX">CRL Distribution Points
		  (CRLDPs)</xref>, then the CRL MAY be retrieved via the mechanism
		  specified in the CRDLP.</t>

		  <t>If the CA supports <xref target="HTTP-certstore">HTTP</xref>,
		  then the CRL MAY be retrieved via the <xref target="PKIX">
		  AuthorityInfoAcces</xref> location specified in the certificate.</t>

		  <t>Only if the CA does not support CRDLPs or HTTP access should a
		  CRL query be composed by creating a GetCRL message consisting of the
		  issuer name and serial number from the certificate whose revocation
		  status is being queried.</t>

		</list>

		</t>
		<t>

The server SHOULD NOT support the GetCRL method because:

		<list style="symbols">

		  <t>It does not scale well due to the unnecessary cryptography (see
		  <xref target="security"/>).</t>

		  <t>It requires the CA to be a high-availability service.</t>

		  <t>Only limited information to determine the CRL scope is provided
		  (see <xref target="PKIX"/>).</t>

		</list>

		</t>
		<t>

The message is sent to the SCEP server in the same way as the other SCEP
requests.  The transaction to retrieve a CRL consists of one GetCRL PKI
message and one CertRep PKI message, which contains only the CRL (no
certificates) in a degenerate certificates-only <xref target="CMS">CMS</xref>
Signed-Data message (<xref target="certs-only"/>), as shown below.

		</t>
		<figure>
		  <artwork><![CDATA[


       REQUESTER                           CA SERVER

   GetCRL: PKI CRL query msg
---------------------------------->
                                  CertRep:  CRL attached
                                  <-----------------------------
Receive the CRL

		  ]]></artwork>
		</figure>
	  </section>
      <section anchor="overview-cert-rev" title="Certificate Revocation">
        <t>

SCEP does not specify a method to request certificate revocation.  In order to
revoke a certificate, the requester must contact the CA using a non-SCEP
defined mechanism.

		</t>
	  </section>
      <section anchor="MTI" title="Mandatory-to-Implement Functionality">
        <t>

At a minimum, all SCEP implementations compliant with this specification MUST
support <xref target="GetCACert">GetCACert</xref>, <xref target="PKCSReq">
PKCSReq</xref> (and its associated response messages), communication of binary
data via <xref target="HTTP-GET-POST">HTTP POST</xref>, and the AES and
SHA-256 algorithms to secure <xref target="pkiMessage">pkiMessages</xref>.

        </t>
        <t>

For historical reasons implementations MAY support communications of binary
data via <xref target="HTTP-GET-POST">HTTP GET</xref>, and the triple DES and
SHA-1 algorithms to secure <xref target="pkiMessage">pkiMessages</xref>.

		</t>
	  </section>
	</section>
    <!-- ====================================================================== -->
    <section anchor="message-obj" title="SCEP Secure Message Objects">
	  <t>

<xref target="CMS">CMS</xref> is a general enveloping mechanism that enables
both signed and encrypted transmission of arbitrary data.  SCEP messages that
require confidentiality use two layers of <xref target="CMS">CMS</xref>, as
shown in <xref target="cms-layering"/>.  By applying both enveloping and
signing transformations, the SCEP message is protected both for the integrity
of its end-to-end transaction information and the confidentiality of its
information portion.  The advantage of this technique over the conventional
transaction message format is that the signed transaction type information and
the status of the transaction can be determined prior to invoking security
handling procedures specific to the information portion being processed.

	  </t>
	  <t>

Some messages do not require enveloping, in which case the Enveloped-Data in
<xref target="cms-layering"/> is omitted.

	  </t>
	  <figure anchor="cms-layering" title="CMS Layering">
		<artwork><![CDATA[

pkiMessage {
  contentType = signedData
  content {
    pkcsPKIEnvelope {   -- Optional
      contentType = envelopedData
      content {
        recipientInfo
        contentType = data
        content {
          messageData   -- Typically PKCS #10 request
          }
        }
      }
    signerInfo {
      signedAttrs {
        transactionID
        messageType
        pkiStatus
        failInfo
        senderNonce
        recipientNonce
        }
      signature
      }
    }
  }

		]]></artwork>
	  </figure>
      <t>

When a particular SCEP message carries data, this data is carried in the
messageData.  CertRep messages will lack any signed content and consist only
of a pkcsPKIEnvelope (<xref target="pkcsPKIEnvelope"/>).

	  </t>
      <t>

Note: The remainder of this document will refer only to 'messageData', but it
is understood to always be encapsulated in the pkcsPKIEnvelope (<xref
target="pkcsPKIEnvelope"/>).  The format of the data in the messageData is
defined by the messageType attribute (see <xref target="pkiMessage"/>) of the
Signed-Data.  If there is no messageData to be transmitted, the entire
pkcsPKIEnvelope MUST be omitted.

	  </t>
	  <section anchor="pkiMessage" title="SCEP pkiMessage">
		<t>

The basic building block of all secured SCEP messages is the SCEP pkiMessage.
It consists of a <xref target="CMS">CMS</xref> Signed-Data content type.  The
following restrictions apply:

		</t>
		<t>

		<list style="symbols">

		  <t>The contentType in contentInfo MUST be data ({pkcs-7 1}) as
			 defined in <xref target="CMS">CMS</xref>.</t>

		  <t>The signed content, if present (e.g. FAILURE and PENDING CertRep
			 messages will lack any signed content), MUST be a pkcsPKIEnvelope
			 (<xref target="pkcsPKIEnvelope"/>), and MUST match the
			 messageType attribute.</t>

		  <t>The SignerInfo MUST contain a set of authenticatedAttributes (see
			 <xref target="CMS">CMS</xref> as well as <xref
			 target="signed-attrs"/> in this document).</t>

		</list>
		</t>

		<t>

At a minimum, all messages MUST contain the following authenticatedAttributes:

		</t>
		<t>

		<list style="symbols">

		  <t>A transactionID attribute (see <xref
		  target="transactionID"/>).</t>

		  <t>A messageType attribute (see <xref target="messageType"/>).</t>

		  <t>A senderNonce attribute (see <xref target="nonces"/>).</t>

		  <t>Any attributes required by <xref target="CMS">CMS</xref>.</t>

		</list>

		</t>
		<t>

If the message is a response, it MUST also include the following
authenticatedAttributes:

		</t>
		<t>

		<list style="symbols">

		  <t>A pkiStatus attribute (see <xref target="pkiStatus"/>).</t>

		  <t>A recipientNonce attribute (see <xref target="nonces"/>).</t>

		</list>

		</t>
		<section anchor="signed-attrs" title="Signed Transaction Attributes">
		  <t>

The following transaction attributes are encoded as authenticated attributes,
and are carried, as specified in <xref target="CMS">CMS</xref>, in the
SignerInfo for this Signed-Data.

		  </t>
		  <texttable align="left">
			<ttcol>Attribute</ttcol>
			<ttcol>Encoding</ttcol>
			<ttcol>Comment</ttcol>

			<c>transactionID</c><c>PrintableString</c><c>Unique ID for this
			transaction as a text string</c>

			<c>messageType</c><c>PrintableString</c><c>Decimal value as a
			numeric text string</c>

			<c>pkiStatus</c><c>PrintableString</c><c>Decimal value as a
			numeric text string</c>

			<c>failInfo</c><c>PrintableString</c><c>Decimal value as a
			numeric text string</c>

			<c>senderNonce</c><c>OCTET STRING</c><c>Random nonce as a 16-byte
			binary data string</c>

			<c>recipientNonce</c><c>OCTET STRING</c><c>Random nonce as a
			16-byte binary data string</c>

		  </texttable>

		  <texttable align="left">
			<preamble>The OIDs used for these attributes are as
			          follows:</preamble>
			<ttcol>Name</ttcol>
			<ttcol>ASN.1 Definition</ttcol>

			<c>id-VeriSign</c><c>OBJECT_IDENTIFIER ::= {2 16 US(840) 1
			   VeriSign(113733)}</c>

			<c>id-pki</c><c>OBJECT_IDENTIFIER ::= {id-VeriSign pki(1)}</c>

			<c>id-attributes</c><c>OBJECT_IDENTIFIER ::= {id-pki
			   attributes(9)}</c>

			<c>id-transactionID</c><c>OBJECT_IDENTIFIER ::= {id-attributes
			   transactionID(7)}</c>

			<c>id-messageType</c><c>OBJECT_IDENTIFIER ::= {id-attributes
			   messageType(2)}</c>

			<c>id-pkiStatus</c><c>OBJECT_IDENTIFIER ::= {id-attributes
			   pkiStatus(3)}</c>

			<c>id-failInfo</c><c>OBJECT_IDENTIFIER ::= {id-attributes
			   failInfo(4)}</c>

			<c>id-senderNonce</c><c>OBJECT_IDENTIFIER ::= {id-attributes
			   senderNonce(5)}</c>

			<c>id-recipientNonce</c><c>OBJECT_IDENTIFIER ::= {id-attributes
				recipientNonce(6)}</c>

		  </texttable>
		  <t>

The attributes are detailed in the following sections.

		  </t>
		  <section anchor="transactionID" title="transactionID">
			<t>

A PKI operation is a transaction consisting of the messages exchanged between
a requester and the server.  The transactionID is a text string generated by
the client when starting a transaction.  The client MUST generate a unique
string as the transaction identifier, which MUST be used for all PKI messages
exchanged for a given enrolment, encoded as a PrintableString.

			</t>
			<t>

One means of generating the transactionID is as a SHA-1, SHA-256, or SHA-512
hash of the public key value in the enrolment request when encoded as an <xref
target="PKIX">X.509 SubjectPublicKeyInfo</xref> (in other words the exact
binary form in which it appears in both the request and the resulting
certificate) and then coverting it into a text string using base64 encoding or
ASCII hex digits.  This allows the SCEP client to automatically generate the
same transactionID for any given public key.  The SCEP protocol requires that
transactionIDs be unique, so that subsequent polling queries can be matched
with previous transactions.

			</t>
			<t>

When using the certificate query and CRL query messages defined in this
protocol, the transactionID is required so that the requester can match the
response message with the outstanding request message.  For a non-enrolment
message (for example GetCert and GetCRL), the transactionID SHOULD be some
value unique to the client.

			</t>
		  </section>
		  <section anchor="messageType" title="messageType">
			<t>

The messageType attribute specifies the type of operation performed by the
transaction.  This attribute MUST be included in all PKI messages.  The
following message types are defined:

			</t>
			<t>

			<list style="symbols">

			  <t>CertRep ("3") -- Response to certificate or CRL request.</t>

			  <t>RenewalReq ("17") -- <xref target="PKCS10">PKCS #10</xref>
			  certificate request for renewal of an existing certificate.</t>

			  <t>UpdateReq ("18") -- <xref target="PKCS10">PKCS #10</xref>
			  certificate request for update of a certificate issued by a
			  different CA.</t>

			  <t>PKCSReq ("19") -- <xref target="PKCS10">PKCS #10</xref>
			  certificate request.</t>

			  <t>CertPoll ("20") -- Certificate polling in manual enrolment.</t>

			  <t>GetCert ("21") -- Retrieve a certificate.</t>

			  <t>GetCRL ("22") -- Retrieve a CRL.</t>

			</list>

			</t>
			<t>

Undefined message types are treated as an error.

			</t>
		  </section>
		  <section anchor="pkiStatus" title="pkiStatus">
			<t>

All response messages MUST include transaction status information, which is
defined as pkiStatus attribute:

			</t>
			<t>

			<list style="symbols">

			  <t>SUCCESS ("0") -- request granted.</t>

			  <t>FAILURE ("2") -- request rejected.  When pkiStatus is
				 FAILURE, the failInfo attribute, as defined in <xref
				 target="failInfo"/>, MUST also be present.</t>

			  <t>PENDING ("3") -- request pending for manual approval.</t>

			</list>

			</t>
			<t>

Undefined pkiStatus attributes are treated as an error.

			</t>
		  </section>
		  <section anchor="failInfo" title="failInfo">
			<t>

The failInfo attribute MUST contain one of the following failure reasons:

			</t>
			<t>

			<list style="symbols">

			  <t>badAlg ("0") -- Unrecognized or unsupported algorithm
				 identifier.</t>

			  <t>badMessageCheck ("1") -- integrity check failed.</t>

			  <t>badRequest ("2") -- transaction not permitted or
			     supported.</t>

			  <t>badTime ("3") -- The signingTime attribute from the <xref
				 target="CMS"> CMS</xref> authenticatedAttributes was not
				 sufficiently close to the system time (see Section
				 3.1.1.6).</t>

			  <t>badCertId ("4") -- No certificate could be identified
				 matching the provided criteria.</t>

			</list>

			</t>

<figure><artwork><![CDATA[
    [Question: Is there any demand for a free-form UTF8String
     attribute to explain what really went wrong?  Trying to sort
     out an error when all you ever get back is the near-universal
     badRequest is almost impossible, adding a failInfoText
     attribute to address this could be quite useful since it
     would allow expressing information such as a failure to meet
     CA policy, or indeed anything more complex than "no go away"].
]]></artwork></figure>

			<t>

Undefined failInfo attributes are treated as an error.

			</t>
		  </section>
		  <section anchor="nonces" title="senderNonce and recipientNonce">
			<t>

The attributes of senderNonce and recipientNonce are a 16 byte random number
generated for each transaction.  These are intended to prevent replay attacks.

			</t>
			<t>

When a sender sends a PKI message to a recipient, a senderNonce MUST be
included in the message.  The recipient MUST copy the senderNonce into the
recipientNonce of the reply as a proof of liveliness.  The original sender
MUST verify that the recipientNonce of the reply matches the senderNonce it
sent in the request.  If the nonce does not match, the message MUST be
rejected.

			</t>

<figure><artwork><![CDATA[
  [Question: What does this do for polling?  Polling messages can
   get lost so nonces will go out of sync, is there a need to
   chain XXXReqs to polls via nonces?  If not, why do we have two
   nonces?].
]]></artwork></figure>


		  </section>
		</section>
		<section anchor="pkcsPKIEnvelope" title="SCEP pkcsPKIEnvelope">
		  <t>

The information portion of a SCEP message is carried inside an Enveloped-Data
content type, as defined in <xref target="CMS">CMS</xref>, with the following
restrictions:

		  </t>
		  <t>

		  <list style="symbols">

			<t>contentType in encryptedContentInfo MUST be data ({pkcs-7 1})
			   as defined in <xref target="CMS">CMS</xref>.</t>

			<t>encryptedContent MUST be the SCEP message being transported
			   (see <xref target="SCEP-trans"/>), and must match the
			   messageType authenticated Attribute in the pkiMessage.</t>

		  </list>

		  </t>
		  <t>

The <xref target="CMS">CMS</xref> content-encryption key is encrypted using
the public key of the recipient of the message, i.e. the CA public key (if
sent from the requester), or the requester public key (if sent as a reply to
the requester).

		  </t>

		</section>
	  </section>
	  <section anchor="pkiMessage-types" title="SCEP pkiMessage types">
		<t>

All of the messages in this section are pkiMessages (<xref
target="pkiMessage"/>), where the type of the message MUST be specified in the
'messageType' authenticated Attribute.  Each section defines a valid message
type, the corresponding messageData formats, and mandatory authenticated
attributes for that type.

		</t>
		<section anchor="PKCSReq" title="PKCSReq/RenewalReq/UpdateReq">
		  <t>

The messageData for this type consists of a <xref target="PKCS10">PKCS
#10</xref> Certification Request.  The certification request MUST contain at
least the following items:

		  </t>
		  <t>

		  <list style="symbols">

			<t>The subject Distinguished Name.</t>

			<t>The subject public key.</t>

			<t>For a PKCSReq and if authorisation based on a password is being
			used, a challengePassword attribute.</t>

		  </list>

		  </t>
		  <t>

In addition to the authenticatedAttributes required for a valid <xref
target="CMS">CMS</xref> message, the pkiMessage MUST include the following
attributes:

		  </t>
		  <t>

		  <list style="symbols">

			<t>A transactionID (<xref target="transactionID"/>) attribute.</t>

			<t>A messageType (<xref target="messageType"/>) attribute set to
			PKCSReq, RenewalReq, or UpdateReq as appropriate.</t>

			<t>A senderNonce (<xref target="nonces"/>) attribute.</t>

		  </list>

		  </t>
		  <t>

The pkcsPKIEnvelope for this message type is protected using the public key of
the recipient as detailed in <xref target="pkcsPKIEnvelope"/>, e.g. either the
CA public key.

		  </t>
		</section>
		<section anchor="CertRep" title="CertRep">
		  <t>

The messageData for this type consists of a degenerate certificates-only <xref
target="CMS">CMS</xref> Signed-Data message (<xref target="certs-only"/>).
The exact content required for the reply depends on the type of request this
message is a reply to.  They are detailed in <xref target="CertRep-success"/>
and in <xref target="SCEP-trans"/>.

		  </t>
		  <t>

In addition to the authenticatedAttributes required for a valid <xref
target="CMS">CMS</xref>, this pkiMessage MUST include the following
attributes:

		  </t>
		  <t>

		  <list style="symbols">

			<t>The transactionID (<xref target="transactionID"/>) attribute
			copied from the request we are responding to.</t>

		    <t>A messageType (<xref target="messageType"/>) attribute set to
			CertRep.</t>

		    <t>A senderNonce (<xref target="nonces"/>) attribute.</t>

		    <t>A recipientNonce attribute (<xref target="nonces"/>) copied
			from the senderNonce from the request that this is a response
			to.</t>

		    <t>A pkiStatus (<xref target="pkiStatus"/>) set to the status of
			the reply.</t>

		  </list>

		  </t>
		  <t>

The pkcsPKIEnvelope for this message type is protected using the public key of
the recipient as detailed in <xref target="pkcsPKIEnvelope"/>.  For example if
a self-signed certificate was used to send the original request then this
self-signed certificate's public key is used to encrypt the content-encryption
key of the SUCCESS response's pkcsPKIEnvelope.

		  </t>
		  <t>

Note that although it may appear that the senderNonce serves no purpose in
this message, it is required if the CertRep contains a PENDING status since
the nonce will be used in subsequent polling operations.

		  </t>
		  <section anchor="CertRep-success" title="CertRep SUCCESS">
		    <t>

When the pkiStatus attribute is set to SUCCESS, the messageData for this
message consists of a degenerate certificates-only <xref target="CMS">
CMS</xref> Signed-Data message (<xref target="certs-only"/>).  The content of
this degenerate certificates-only Signed-Data depends on what the original
request was, as outlined below.

		    </t>
			<texttable align="left">

			  <ttcol>Request-type</ttcol>
			  <ttcol>Reply-contents</ttcol>

			  <c>PKCSReq</c><c>The reply MUST contain at least the issued
				 certificate in the certificates field of the Signed-Data.
				 The reply MAY contain additional certificates, but the issued
				 certificate MUST be the leaf certificate.  The reply MUST NOT
				 contain a CRL.</c>

			  <c>RenewalReq</c><c>Same as PKCSReq</c>

			  <c>UpdateReq</c><c>Same as PKCSReq</c>

			  <c>CertPoll</c><c>Same as PKCSReq</c>

			  <c>GetCert</c><c>The reply MUST contain at least the requested
				 certificate in the certificates field of the Signed-Data.
				 The reply MAY contain additional certificates, but the
				 requested certificate MUST be the leaf certificate.  The
				 reply MUST NOT contain a CRL.</c>

			  <c>GetCRL</c><c>The reply MUST contain the CRL in the crls field
				 of the Signed-Data.  The reply MUST NOT contain a
				 certificate.</c>

			</texttable>
		  </section>
		  <section anchor="CertRep-failure" title="CertRep FAILURE">
		    <t>

When the pkiStatus attribute is set to FAILURE, the reply MUST also contain a
failInfo (<xref target="failInfo"/>) attribute set to the appropriate error
condition describing the failure.  The pkcsPKIEnvelope (<xref
target="pkcsPKIEnvelope"/>) MUST be omitted.

		    </t>
		  </section>
		  <section anchor="CertRep-pending" title="CertRep PENDING">
		    <t>

When the pkiStatus attribute is set to PENDING, the pkcsPKIEnvelope (<xref
target="pkcsPKIEnvelope"/>) MUST be omitted.

		    </t>
		  </section>
	    </section>
	    <section anchor="CertPoll" title="CertPoll (GetCertInitial)">
		  <t>

This message is used for certificate polling.  For unknown reasons it was
referred to as "GetCertInitial" in earlier drafts.  The messageData for this
type consists of an IssuerAndSubject:

	      </t>

		  <figure>
			<artwork><![CDATA[

issuerAndSubject ::= SEQUENCE {
    issuer Name,
    subject Name
    }

			]]></artwork>
		  </figure>

		  <t>

The issuer is set to the subjectName of the CA (in other words the intended
issuerName of the certificate that's being requested).  The Subject is set to
the subjectName used when requesting the certificate.

		  </t>
		  <t>

In addition to the authenticatedAttributes required for a valid <xref
target="CMS">CMS</xref>, this pkiMessage MUST include the following
attributes:

		  </t>
		  <t>

		  <list style="symbols">

		    <t>The same transactionID (<xref target="transactionID"/>)
			attribute from the original PKCSReq/RenewalReq/UpdateReq
			message.</t>

		    <t>A messageType (<xref target="messageType"/>) attribute set to
			CertPoll.</t>

		    <t>A senderNonce (<xref target="nonces"/>) attribute.</t>

		    <t>A recipientNonce attribute (<xref target="nonces"/>) copied
			from the senderNonce from the request that this is a response
			to.</t>

		  </list>

		  </t>
	    </section>
	    <section anchor="GetCert" title="GetCert">
		  <t>

The messageData for this type consists of an IssuerAndSerialNumber as defined
in <xref target="CMS">CMS</xref> which uniquely identifies the certificate
being requested.

		  </t>
		  <t>

In addition to the authenticatedAttributes required for a valid <xref
target="CMS">CMS</xref>, this pkiMessage MUST include the following
attributes:

		  </t>
		  <t>

		  <list style="symbols">

		    <t>A transactionID (<xref target="transactionID"/>) attribute.</t>

		    <t>A messageType (<xref target="messageType"/>) attribute set to
			   GetCert.</t>

		    <t>A senderNonce (<xref target="nonces"/>) attribute.</t>

		  </list>

		  </t>
		  <t>

A self-signed certificate MAY be used in the signed envelope.  This enables
the requester to request their own certificate if they were unable to store it
previously.

		  </t>
	    </section>
	    <section anchor="GetCRL" title="GetCRL">
		  <t>

The messageData for this type consists of a IssuerAndSerialNumber as defined
in <xref target="CMS">CMS</xref> containing the issuer name and serial number
of the certificate whose revocation status is being checked.

		  </t>
		  <t>

In addition to the authenticatedAttributes required for a valid <xref
target="CMS">CMS</xref>, this pkiMessage MUST include the following
attributes:

		  </t>
		  <t>

		  <list style="symbols">

		    <t>A transactionID (<xref target="transactionID"/>) attribute.</t>

		    <t>A messageType (<xref target="messageType"/>) attribute set to
			   GetCRL.</t>

		    <t>A senderNonce (<xref target="nonces"/>) attribute.</t>

		  </list>

		  </t>
	    </section>
	  </section>
      <section anchor="certs-only" title="Degenerate certificates-only CMS Signed-Data">
	    <t>

<xref target="CMS">CMS</xref> includes a degenerate case of the <xref
target="CMS">CMS</xref> Signed-Data content type, in which there are no
signers.  The use of such a degenerate case is to disseminate certificates and
CRLs.  For SCEP the content field of the ContentInfo value of a degenerate
certificates-only Signed-Data MUST be omitted.

	    </t>
	    <t>

When carrying certificates, the certificates are included in the
'certificates' field of the Signed-Data.  When carrying a CRL, the CRL will be
included in the 'crls' field of the Signed-Data.

	    </t>
	  </section>
      <section anchor="CA-caps" title="CA Capabilities">
        <t>

In order to provide support for future enhancements to the protocol, CAs
SHOULD implement the GetCACaps message to allow clients to query which
functionality is available from the CA.

        </t>
	    <section anchor="CA-caps-HTTP" title="GetCACaps HTTP Message Format">

		  <figure>
		    <preamble>This message requests capabilities from a CA, with the
					  format:</preamble>
		    <artwork><![CDATA[

"GET" CGI-PATH CGI-PROG "?operation=GetCACaps"

		    ]]></artwork>
		  </figure>

		  <t>

with the message components as described in <xref target="transport"/>.  The
response is a list of text capabilities, as defined in <xref
target="CA-caps-resp"/>.  CA servers SHOULD support the GetCACaps message and
MUST support it when they implement any extended functonality beyond the
mandatory-to-implement basics <xref target="MTI"/>.

		  </t>
	    </section>
	    <section anchor="CA-caps-resp" title="CA Capabilities Response Format">

		  <texttable align="left">
		    <preamble>The response for a GetCACaps message is a list of CA
					  capabilities, in plain text, separated by &lt;LF&gt;
					  characters, as follows (quotation marks are NOT
					  sent):</preamble>
		    <ttcol>Keyword</ttcol>
		    <ttcol>Description</ttcol>

		    <c>"AES"</c><c>CA Supports the AES encryption algorithm.</c>

		    <c>"DES3"</c><c>CA Supports the triple DES encryption
			   algorithm.</c>

		    <c>"GetNextCACert"</c><c>CA Supports the GetNextCACert
				message.</c>

		    <c>"POSTPKIOperation"</c><c>PKIOPeration messages may be sent via
			   HTTP POST.</c>

		    <c>"Renewal"</c><c>CA Supports the Renewal CA operation.</c>

		    <c>"SHA-1"</c><c>CA Supports the SHA-1 hashing algorithm.</c>

		    <c>"SHA-256"</c><c>CA Supports the SHA-256 hashing algorithm.</c>

		    <c>"SHA-512"</c><c>CA Supports the SHA-512 hashing algorithm.</c>

		    <c>"Update"</c><c>CA Supports the Update CA operation.</c>

		  </texttable>

		  <t>

The client SHOULD use SHA-256 or SHA-512 in preference to SHA-1 hashing, and
AES in preference to triple DES if they are supported by the CA.  Although the
CMS format allows any form of SHA-2 and AES to be specified, in the interests
of interoperability it is RECOMMENDED that the de facto universal standards of
AES128-CBC and SHA-256 be used.

		  </t>
		  <t>

Announcing some of these capabilities is redundant since they're required as
mandatory-to-implement functionality (see <xref target="MTI"/>), but it may be
useful to announce them in order to deal with old implementations that would
otherwise default to obsolete, insecure algorithms and mechanisms.

		  </t>
		  <t>

The server MUST use the texual case specified here, but clients SHOULD ignore
the textual case when processing this message.  A client MUST be able to
accept and ignore any unknown keywords that might be sent back by a CA.

		  </t>
		  <t>

If the CA supports none of the above capabilities the SCEP server SHOULD
return an empty message.  A server MAY simply return an HTTP error.  A client
that receives an empty message or an HTTP error SHOULD interpret the response
as if none of the requested capabilities are supported by the CA.

		  </t>
		  <t>

(Note that at least one widely-deployed server implementation supports several
of the above operations but doesn't support the GetCACaps message to indicate
that it supports them.  This means that the equivalent of GetCACaps must be
performed through server fingerprinting, which can be done using the ID string
"Microsoft-IIS").

		  </t>
		  <t>

The Content-type of the reply SHOULD be "text/plain".  Clients SHOULD ignore
the Content-type, as older server implementations of SCEP may send various
Content-types.

		  </t>
		  <figure>
		    <preamble>Example:</preamble>
		    <artwork><![CDATA[

GET /cgi-bin/pkiclient.exe?operation=GetCACaps

		    ]]></artwork>
		  </figure>

		  <figure>
		    <preamble>might return:</preamble>
		    <artwork><![CDATA[

AES
SHA-256
GetNextCACert
POSTPKIOperation

		    ]]></artwork>
		  </figure>
		  <t>

This means that the CA supports modern crypto algorithms, the GetNextCACert
message, and allows PKIOperation messages (PKCSReq/RenewalReq/UpdateReq,
GetCert, CertPoll, ...) to be sent using HTTP POST.

		  </t>

	    </section>
	  </section>
	</section>
	<section anchor="SCEP-trans" title="SCEP Transactions">
	  <t>

This section describes the SCEP Transactions, without explaining the
transport.  The transport of each message is discussed in <xref
target="transport"/>.  Some of the transaction-requests have no data to send,
i.e. the only data is the message-type itself (e.g. a GetCACert message has no
additional data).

	  </t>
	  <t>

In this section, each SCEP transaction is specified in terms of the complete
messages exchanged during the transaction.

	  </t>
	  <section anchor="GetCACert" title="Get CA Certificate">
		<t>

To get the CA certificate(s), the requester sends a GetCACert message to the
server.  There is no request data associated with this message (see <xref
target="HTTP-GetCACert"/>).

		</t>
		<section anchor="GetCACert-resp" title="Get CA Certificate Response Message Format">
		  <t>

The server MUST indicate which response it is sending via the transport
protocol used (see <xref target="HTTP-GetCACert"/>).  If the requester does
not have a certificate path to a trust anchor certificate, the SHA-1, SHA-256,
or SHA-512 fingerprint of the returned CA certificate (communicated via out-
of- band means) may be used to verify it.

		  </t>
		  <t>

All returned certificates MUST conform to <xref target="PKIX">PKIX</xref>.

		  </t>
		  <section anchor="GetCACert-resp-format" title="CA Certificate Response Message Format">
			<t>

If the server does not have any intermediate CA certificates, the response
consists of a single X.509 CA certificate.

			</t>
		  </section>
		  <section anchor="GetCACertChain-resp-format" title="CA Certificate Chain Response Message Format">
			<t>

If the server has intermediate CA certificates, the response consists of a
degenerate certificates-only <xref target="CMS">CMS</xref> Signed-Data (<xref
target="certs-only"/>) containing the certificates, with the intermediate CA
certificate(s) as the leaf certificate(s).

			</t>
		  </section>
		</section>
	  </section>
	  <section anchor="cert-enrolment" title="Certificate Enrolment/Renewal/Update">
		<t>

A PKCSReq/RenewalReq/UpdateReq (<xref target="PKCSReq"/>) message is used to
perform a certificate enrolment, renewal, or update transaction.

		</t>
		<t>

The reply MUST be a CertRep (<xref target="CertRep"/>) message sent back from
the server, indicating SUCCESS, FAILURE, or PENDING.

		</t>
		<t>

Precondition: Both the requester and the certification authority have
completed their initialization process.  The requester has already been
configured with the CA certificate.

		</t>
		<t>

Postcondition: The requester receives the certificate, the request is
rejected, or the request is pending.  A pending response might indicate that
manual authentication is necessary.

		</t>
		<section anchor="cert-enrolment-resp" title="Certificate Enrolment/Renewal/Update Response Message">
		  <t>

If the request is granted, a CertRep (<xref target="CertRep"/>) message with
pkiStatus set to SUCCESS is returned.  The reply MUST also contain the
certificate (and MAY contain any other certificates needed by the requester).
The issued certificate MUST be the first in the list.

		  </t>
		  <t>

If the request is rejected, a CertRep (<xref target="CertRep"/>) message with
pkiStatus set to FAILURE is returned.  The reply MUST also contain a failInfo
attribute.

		  </t>
		  <t>

If the the CA is configured to manually authenticate the requester, a CertRep
(<xref target="CertRep"/>) message with pkiStatus set to PENDING MAY be
returned.  The CA MAY return a PENDING for other reasons.

		  </t>
		</section>
	  </section>
	  <section anchor="poll-resp" title="Poll for Requester Initial Certificate">
		<t>

Triggered by a CertRep (<xref target="CertRep"/>) with pkiStatus set to
PENDING, a requester will enter the polling state by periodically sending
CertPoll messages (<xref target="CertPoll"/>) to the server, until either the
request is granted and the certificate is sent back, or the request is
rejected, or some preconfigured time limit for polling or maximum number of
polls is exceeded.

		</t>
		<t>

CertPoll messages exchanged during the polling period MUST carry the same
transactionID attribute as the previous PKCSReq/RenewalReq/UpdateReq.  A
server receiving a CertPoll for which it does not have a matching
PKCSReq/RenewalReq/UpdateReq MUST ignore this request.

		</t>
		<t>

Since at this time the certificate has not been issued, the requester can only
use its own subject name (which was contained in the original PKCS# 10 sent
via PKCSReq/RenewalReq/UpdateReq) to identify the polled certificate request.
In theory there can be multiple outstanding requests from one requester (for
example, if different keys and different key-usages were used to request
multiple certificates), so the transactionID must also be included to
disambiguate between multiple requests.  In practice however it's safer for
the requester to not have multiple requests outstanding at any one time, since
this tends to confuse some servers.

		</t>
		<t>

PreCondition: The requester has received a CertRep with pkiStatus set to
PENDING.

		</t>
		<t>

PostCondition: The requester has either received a valid response, which could
be either a valid certificate (pkiStatus = SUCCESS), or a FAILURE message, or
the polling period times out.

		</t>
		<section anchor="poll-resp-format" title="Polling Response Message Format">
		  <t>

The response messages for CertPoll are the same as in <xref
target="cert-enrolment-resp"/>.

		  </t>
		</section>
	  </section>
	  <section anchor="cert-access" title="Certificate Access">
		<t>

A requester can query an issued certificate from the SCEP server, as long as
the requester knows the issuer name and the issuer assigned certificate serial
number.

		</t>
		<t>

This transaction consists of one GetCert (<xref target="GetCert"/>) message
sent to the server by a requester, and one CertRep (<xref target="CertRep"/>)
message sent back from the server.

		</t>
		<t>

PreCondition: The certification authority has issued the queried certificate
and the issuer assigned serial number is known.

		</t>
		<t>

PostCondition: Either the certificate is sent back or the request is rejected.

		</t>
		<section anchor="cert-access-resp" title="Certificate Access Response Message Format">
		  <t>

In this case, the CertRep from the server is same as in Section <xref
target="cert-enrolment-resp"/>, except that the server will only either grant
the request (SUCCESS) or reject the request (FAILURE).

		  </t>
		</section>
	  </section>
	  <section anchor="CRL-access" title="CRL Access">
		<t>

Clients can request a CRL from the SCEP server as described in <xref
target="overview-CRL-access"/>.

		</t>
		<t>

PreCondition: The certification authority certificate has been downloaded to
the end entity.

		</t>
		<t>

PostCondition: CRL sent back to the requester.

		</t>
		<section anchor="CRL-access-resp" title="CRL Access Response Message Format">
		  <t>

The CRL is sent back to the requester in a CertRep (<xref target="CertRep"/>)
message.  The information portion of this message is a degenerate
certificates-only Signed-Data (<xref target="certs-only"/>) that contains only
the most recent CRL in the crls field of the Signed-Data.

		  </t>
		</section>
	  </section>
	  <section anchor="get-next-CA" title="Get Next Certification Authority Certificate">
		<t>

When the CA certificate expires all certificates that have been signed by it
are no longer valid.  CA key rollover provides a mechanism by which the server
MAY distribute a new CA certificate which is valid in the future; when the
current certificate has expired.  When a CA certificate is about to expire,
clients need to retrieve the CA's next CA certificate (i.e. the rollover
certificate).  This is done via the GetNextCACert message.  There is no
request data associated with this message (see <xref
target="HTTP-GetNextCACert"/>).

	    </t>
	    <t>

Clients MUST store the not-yet-valid CA certificate, and any not-yet-valid
client certificates obtained, until such time that they are valid, at which
point clients switch over to using the newly valid certificates.

		</t>
		<section anchor="get-next-CA-format" title="Get Next CA Response Message Format">
		  <t>

The response consists of a Signed-Data <xref target="CMS">CMS</xref>, signed
by the current CA signing key.  Clients MUST validate the signature on the the
Signed-Data <xref target="CMS"> CMS</xref> before accepting any of its
contents.

		  </t>
		  <t>

The content of the Signed-Data <xref target="CMS">CMS</xref> message is a
degenerate certificates-only Signed-Data (<xref target="certs-only"/>) message
containing the new CA certificate(s) as defined in <xref
target="HTTP-GetCACert-resp-ca"/>, to be used when the current CA certificate
expires.

		  </t>
		  <t>

If the CA does not have the rollover certificate(s) it MUST reject the
request.  It SHOULD also remove the GetNextCACert setting from the
capabilities until it does have rollover certificates.

		  </t>
		  <t>

If there are any intermediate CA certificates in this response, clients MUST
check that these certificates are signed by the CA, and MUST check
authorization of these intermediate CA certificates (see <xref
target="overview-ca"/>).

		  </t>
		</section>
	  </section>
	</section>
    <!-- ====================================================================== -->
	<section anchor="transport" title="SCEP Transport">
	  <t>

<xref target="HTTP">HTTP</xref> is used as the transport protocol for SCEP
Message Objects.

	  </t>
	  <section anchor="HTTP-GET-POST" title="HTTP GET and POST Message Formats">
		<t>

SCEP uses the HTTP "GET" and "POST" messages to exchange information with the
CA.  The following defines the syntax of a HTTP GET and POST messages sent
from a requester to a certification authority server:

		</t>
		<figure>
		  <artwork><![CDATA[

"GET" CGI-PATH CGI-PROG "?operation=" OPERATION "&message=" MESSAGE
"POST" CGI-PATH CGI-PROG "?operation=" OPERATION

		  ]]></artwork>
		</figure>
		<t>

where:

		</t>
        <t>

      	<list style="symbols">

		  <t>CGI-PATH defines the actual CGI path to invoke the CGI program
		  that parses the request.</t>

		  <t>CGI-PROG is set to be the string "pkiclient.exe".  This is
		  intended to be the program that the CA will use to handle the SCEP
		  transactions, though the CA may ignore CGI-PROG and use only the
		  CGI-PATH, or ignore both if it's not issuing certificates via a web
		  server.  Typically, setting CGI-PATH/CGI-PROG to
		  "/cgi-bin/pkiclient.exe" will satisfy most servers.</t>

		  <t>OPERATION depends on the SCEP transaction and is defined in the
		  following sections.</t>

		  <t>MESSAGE depends on the SCEP transaction and is defined in the
		  following sections.</t>

        </list>

        </t>
        <t>

Early SCEP drafts performed all communications via "GET" messages, including
non-idempotent ones that should have been sent via "POST" messages.  This has
caused problems because of the way that the (supposedly) idempotent GET
interacts with caches and proxies, and because the extremely large GET
requests created by encoding CMS messages may be truncated in transit.  These
issues are typically not visible when testing on a LAN, but crop up during
deployment over WANs.  If the remote CA supports it, any of the <xref
target="CMS">CMS</xref>-encoded SCEP messages SHOULD be sent via HTTP POST
instead of HTTP GET.  This is allowed for any SCEP message except GetCACert,
GetNextCACert, or GetCACaps, and avoids the need for base64- and URL-encoding
that's required for GET messaging.  The client can verify that the CA supports
SCEP messages via POST by looking for the "POSTPKIOperation" capability (See
<xref target="CA-caps-resp"/>).

        </t>
        <t>

If your client or server uses HTTP GET and encounters HTTP-related problems
such as messages being truncated, seeing errors such as HTTP 414 ("Request URI
too long"), or simply having the message not sent/received at all, when
standard requests to the server (for example via a web browser) work, then
this is a symptom of the problematic use of HTTP GET.  The solution to this
problem is typically to move to HTTP POST instead.  In addition when using GET
it's recommended to test your implementation over the public internet from as
many locations as possible to determine whether the use of GET will cause
problems with communications.

        </t>
        <t>

When using GET messages to communicate binary data, base64 encoding as
specified in <xref target="Base64"/> MUST be used.  The base64 encoded data is
distinct from "base64url" and may contain URI reserved characters, thus it
MUST be escaped as specified in <xref target="URI"/> in addition to being
bas64 encoded.

        </t>
	    <section anchor="resp-format" title="Response Message Format">
		  <t>

For each GET or POST operation, the CA server MUST return a Content-Type and
appropriate response data, if any.

          </t>
	    </section>
	  </section>
	  <section anchor="HTTP-messages" title="SCEP HTTP Messages">
		<t>

This section describes the OPERATION and MESSAGE values for SCEP exchanges.

		</t>
		<section anchor="HTTP-GetCACert" title="GetCACert">
		  <t>

The OPERATION MUST be set to "GetCACert".

		  </t>
		  <section anchor="HTTP-GetCACert-resp" title="GetCACert Response">
			<t>

The response for GetCACert is different between the case where the CA directly
communicates with the requester during the enrolment, and the case where an
intermediate CA exists and the requester communicates with this CA during the
enrolment.

			</t>
			<section anchor="HTTP-GetCACert-resp-certonly" title="CA Certificate Only Response">
			  <t>

The response will have a Content-Type of "application/x-x509-ca-cert".

			  </t>
			  <t>

The body of this response consists of an X.509 CA certificate, as defined in
<xref target="GetCACert-resp-format"/>:

			  </t>
			  <figure>
				<artwork><![CDATA[

"Content-Type:application/x-x509-ca-cert"

<binary X.509>

				]]></artwork>
			  </figure>
			</section>
			<section anchor="HTTP-GetCACert-resp-ca" title="CA Certificate Chain Response">
			  <t>

The response will have a Content-Type of "application/x-x509-ca-ra-cert".
Note that this designation is used for historical reasons due to its use in
older SCEP drafts, no special meaning should be attached to the label itself.

			  </t>
			  <t>

The body of this response consists of a degenerate certificates-only <xref
target="CMS">CMS</xref> Signed-Data (<xref target="certs-only"/>) message
containing both CA and intermediate CA certificates, as defined in <xref
target="GetCACertChain-resp-format"/>:

			  </t>
			  <figure>
				<artwork><![CDATA[

"Content-Type:application/x-x509-ca-ra-cert"

<binary CMS>

				]]></artwork>
			  </figure>
			</section>
		  </section>
		</section>
		<section anchor="HTTP-PKCSReq" title="PKCSReq/RenewalReq/UpdateReq">
		  <t>

The OPERATION MAY be set to "PKIOperation".  When used with HTTP POST, the
only OPERATION possible is "PKIOperation", so many servers don't check this
values or even notice its absence.

		  </t>
		  <t>

The MESSAGE consists of a PKCSReq, RenewalReq, or UpdateReq SCEP message.
When implemented using HTTP POST this might look as follows:

		  </t>
		  <figure>
			<artwork><![CDATA[

POST /cgi-bin/pkiclient.exe?operation=PKIOperation HTTP/1.1
Content-Length: <length of data>

<binary CMS data>

			  ]]></artwork>
			</figure>
		  <t>

When implemented using HTTP GET this might look as follows:

		  </t>
		  <figure>
			<artwork><![CDATA[

GET /cgi-bin/pkiclient.exe?operation=PKIOperation& \
message=MIAGCSqGSIb3DQEHA6CAMIACAQAxgDCBzAIBADB2MG \
IxETAPBgNVBAcTCE......AAAAAA== HTTP/1.1

			  ]]></artwork>
			</figure>
		  <section anchor="HTTP-PKCSReq-resp" title="PKCSReq/RenewalReq/UpdateReq Response">
			<t>

The response will have a Content-Type of "application/x-pki-message".

			</t>
			<t>

The body of this response consists of a CertRep SCEP message defined in <xref
target="cert-enrolment-resp"/>.  The following is an example of the response:

			</t>
			<figure>
			  <artwork><![CDATA[

"Content-Type:application/x-pki-message"

<binary CertRep msg>

			  ]]></artwork>
			</figure>
		  </section>
		</section>
		<section anchor="HTTP-CertPoll" title="CertPoll">
		  <t>

The OPERATION MUST be set to "PKIOperation".  The MESSAGE consists of a
CertPoll SCEP message.

		  </t>
		  <section anchor="HTTP-CertPoll-resp" title="CertPoll Response">
			<t>

The body of this response consists of a CertRep SCEP message defined in <xref
target="poll-resp-format"/>.

			</t>
		  </section>
		</section>
		<section anchor="HTTP-GetCert" title="GetCert">
		  <t>

The OPERATION MUST be set to "PKIOperation".  The MESSAGE consists of a
GetCert SCEP message.

		  </t>
		  <section anchor="HTTP-GetCert-resp" title="GetCert Response">
			<t>

The body of this response consists of a CertRep SCEP message defined
in <xref target="cert-access-resp"/>.

			</t>
		  </section>
		</section>
		<section anchor="HTTP-GetCRL" title="GetCRL">
		  <t>

The OPERATION MUST be set to "PKIOperation".  The MESSAGE consists of a GetCRL
SCEP message.

		  </t>
		  <section anchor="HTTP-GetCRL-resp" title="GetCRL Response">
			<t>

The body of this response consists of a CertRep SCEP message defined in <xref
target="CRL-access-resp"/>.

			</t>
		  </section>
		</section>
		<section anchor="HTTP-GetNextCACert" title="GetNextCACert">
		  <t>

The OPERATION MUST be set to "GetNextCACert".

		  </t>
		  <section anchor="HTTP-GetNextCACert-resp" title="GetNextCACert Response">
			<t>

The response will have a Content-Type of "application/x-x509-next-ca-cert".

			</t>
			<t>

The body of this response consists of a Signed-Data <xref target="CMS">
CMS</xref>, as defined in <xref target="get-next-CA-format"/>. (This is
similar to the GetCert response but does not include any of the attributes
defined in <xref target="signed-attrs"/>).

			</t>
			<figure>
			  <artwork><![CDATA[

"Content-Type:application/x-x509-next-ca-cert"

<binary CMS>

			  ]]></artwork>
			</figure>
		  </section>
		</section>
	  </section>
	</section>
    <!-- ====================================================================== -->
    <section anchor="ack" title="Contributors/Acknowledgements">
	  <t>

The editor would like to thank all the previous editors, authors and
contributors: Cheryl Madson, Xiaoyi Liu, David McGrew, David Cooper, Andy
Nourse, Max Pritikin, Jan Vilhuber, etc for their work maintaining the draft
over the years.  Numerous other people have contributed during the long life
cycle of the draft and all deserve thanks.

	  </t>
	  <t>

The earlier authors would like to thank Peter William of ValiCert, Inc.
(formerly of VeriSign, Inc.) and Alex Deacon of VeriSign, Inc. and Christopher
Welles of IRE, Inc. for their contributions to early versions of this protocol
and this document.

	  </t>
	</section>
    <!-- ====================================================================== -->
    <section anchor="iana" title="IANA Considerations">
	  <t>

This memo includes no request to IANA.

	  </t>
	</section>
    <!-- ====================================================================== -->
    <section anchor="security" title="Security Considerations">
	  <t>

The security goals of SCEP are that no adversary can:

	  </t>
	  <t>

	  <list style="symbols">

		<t>Subvert the public key/identity binding from that intended.</t>

		<t>Discover the identity information in the enrolment requests and
		issued certificates.</t>

	  </list>

	  </t>
	  <t>

Here an adversary is any entity other than the requester and the CA
participating in the protocol.  The adversary is computationally limited, but
that can manipulate data during transmission (that is, can act as a MITM).
The precise meaning of 'computationally limited' depends on the implementer's
choice of one-way hash functions and cryptographic algorithms.

	  </t>
	  <t>

The first and second goals are met through the use of <xref target="CMS">
CMS</xref> and <xref target="PKCS10">PKCS #10</xref> encryption and digital
signatures using authenticated public keys.  The CA's public key is
authenticated via out-of-band means such as the checking of the CA
fingerprint, as specified in <xref target="overview-ca"/>, and the SCEP
client's public key is authenticated through manual or pre-shared secret
authentication, as specified in <xref target="overview-req-auth"/>.

	  </t>
	  <t>

The motivation of the first security goal is straightforward.  The motivation
for the second security goal is to protect the identity information in the
enrolment requests and issued certificates. Subsequent protocols can use the
certificate in ways that either expose the identity information, or protect
it, depending on the security requirements of those protocols.  The motivation
for the third security goal is to protect the SCEP clients from denial of
service attacks.

	  </t>
	  <section title="General Security">
		<t>

Common key-management considerations such as keeping private keys truly
private and using adequate lengths for symmetric and asymmetric keys must be
followed in order to maintain the security of this protocol.  This is
especially true for CA keys, which, when compromised, compromise the security
of all relying parties.

		</t>
	  </section>
	  <section title="Use of the CA keypair">
		<t>

A CA key pair is generally meant for (and is usually flagged as) certificate
(and CRL) signing exclusively, rather than data signing or encryption. The
SCEP protocol, however, uses the CA private key to both encrypt and sign <xref
target="CMS">CMS</xref> transport messages.  This is generally considered
undesirable, as it widens the possibility of an implementation weakness, and
provides:

		</t>
		<t>

		<list style="symbols">

		  <t>Another place that the private key must be used (and hence is
		     slightly more vulnerable to exposure).</t>

		  <t>Another place where a side channel attack (say, timing or power
		  	 analysis) might be used.</t>

		  <t>Another place that the attacker might somehow insert their own
			 data and get it signed by the CA's private key (note that this
			 issue is purely theoretical, since the CMS data signed by the CA
			 is nothing remotely like a certificate and couldn't be passed off
			 as such).</t>

		</list>

		</t>
	  </section>
	  <section title="Challenge Password">
		<t>

The challengePassword sent in the PKCS #10 enrolment request is signed and
encrypted by way of being encapsulated in a pkiMessage. When saved by the CA,
care should be taken to protect this password.

		</t>
		<t>

If the challengePassword is used to automatically authenticate an enrolment
request, it is recommended that some form of one-time password be used to
minimize damage in the event the data is compromised.

		</t>
	  </section>
	  <section title="Transaction ID">
		<t>

CAs SHOULD NOT rely on the transactionID to be correct or as specified in this
document.  Requesters with buggy software might add additional undetected
duplicate requests to the CA's queue.  A well-written CA should never assume
the data from a requester is well-formed.

		</t>
	  </section>
	  <section title="Nonces and Replay">
		<t>

In order to detect replay attacks, both sides need to maintain state
information sufficient to detect an unexpected nonce value.

		</t>
	  </section>
	  <section title="GetCACaps Issues">
		<t>

The GetCACaps response is not signed.  This allows an attacker to perform
downgrade attacks on the cryptographic capabilities of the client/CA exchange.

		</t>
	  </section>
	  <section title="Unnecessary cryptography">
		<t>

Some of the SCEP exchanges use signing and encryption operations that are not
necessary.  In particular the GetCert and GetCRL exchanges are encrypted and
signed in both directions.  The information requested is public and thus
signing the requests is of questionable value but also CRLs and Certificates,
i.e. the respective responses, are already signed by the CA and can be
verified by the recipient without requiring additional signing and encryption.

		</t>
		<t>

This may affect performance and scalability of the CA and could be used as an
attack vector on the CA (though not an anonymous one).  The use of CRLDPs as
well as other ways of retrieving certificates such as HTTP access and LDAP are
recommended for CRL access.

		</t>
	  </section>
	  <section title="GetNextCACert">
		<t>

GetNextCACert depends on a 'flag moment' at which every client in the PKI
infrastructure switches from the current CA certificate (and client
certificate) to the new CA certificate and client certificates.  Proper
monitoring of the network infrastructure can ensure that this will proceed as
expected but any errors in processing or implementation can result in a
failure of the PKI infrastructure.

		</t>
	  </section>
    </section>
    <!-- ====================================================================== -->

  </middle>
  <!-- ======================================================================== -->
  <back>

    <references title="Normative References">

      <reference anchor='RFC2119'>
        <front>
          <title abbrev='RFC Key Words'>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author initials='S.' surname='Bradner' fullname='Scott Bradner'>
            <organization>Harvard University</organization>
          </author>
          <date year='1997' month='March' />
          <area>General</area>
          <keyword>keyword</keyword>
        </front>
        <seriesInfo name='BCP' value='14' />
        <seriesInfo name='RFC' value='2119' />
        <format type='TXT' target='ftp://ftp.isi.edu/in-notes/rfc2119.txt' />
        <format type='HTML' target='http://xml.resource.org/public/rfc/html/rfc2119.html' />
        <format type='XML' target='http://xml.resource.org/public/rfc/xml/rfc2119.xml' />
      </reference>

      <reference anchor='Base64'>
        <front>
          <title>The Base16, Base32, and Base64 Data Encodings</title>
          <author initials="S" surname="Josefsson"></author>
          <date year='2006' month='October' />
        </front>
        <seriesInfo name='RFC' value='4648' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc4648.txt' />
      </reference>

      <reference anchor='CMS'>
        <front>
          <title>Cryptographic Message Syntax (CMS)</title>
          <author initials="R" surname="Housley"></author>
          <date year='2009' month='September' />
        </front>
        <seriesInfo name='RFC' value='5652' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc5652.txt' />
      </reference>

      <reference anchor='HTTP'>
        <front>
          <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
          <author initials="R" surname="Fielding"></author>
          <author initials="J" surname="Gettys"></author>
          <author initials="J" surname="Mogul"></author>
          <author initials="H" surname="Frystyk"></author>
          <author initials="L" surname="Masinter"></author>
          <author initials="P" surname="Leach"></author>
          <author initials="T" surname="Berners-Lee"></author>
          <date year='1999' month='June' />
        </front>
        <seriesInfo name='RFC' value='2616' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc2616.txt' />
      </reference>

      <reference anchor='PKCS9'>
        <front>
          <title>PKCS #9: Selected Object Classes and Attribute Types Version 2.0</title>
          <author initials="M" surname="Nystrom"></author>
          <author initials="B" surname="Kaliski"></author>
          <date year='2000' month='November' />
        </front>
        <seriesInfo name='RFC' value='2985' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc2985.txt' />
      </reference>

      <reference anchor='PKCS10'>
        <front>
          <title>PKCS #10: Certification Request Syntax Specification Version 1.7</title>
          <author initials="M" surname="Nystrom"></author>
          <author initials="B" surname="Kaliski"></author>
          <date year='2000' month='November' />
        </front>
        <seriesInfo name='RFC' value='2986' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc2986.txt' />
      </reference>

      <reference anchor='PKIX'>
        <front>
          <title>PKCS #10: Certification Request Syntax Specification Version 1.7</title>
          <author initials="D" surname="Cooper"></author>
          <author initials="S" surname="Santesson"></author>
          <author initials="S" surname="Farrell"></author>
          <author initials="S" surname="Boeyen"></author>
          <author initials="R" surname="Housley"></author>
          <author initials="W" surname="Polk"></author>
          <date year='2008' month='May' />
        </front>
        <seriesInfo name='RFC' value='5280' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc5280.txt' />
      </reference>

      <reference anchor='URI'>
        <front>
          <title>Uniform Resource Identifiers (URI): Generic Syntax</title>
          <author initials="T" surname="Berners-Lee"></author>
          <author initials="R" surname="Fielding"></author>
          <author initials="L" surname="Masinter"></author>
          <date year='1998' month='August' />
        </front>
        <seriesInfo name='RFC' value='2396' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc2396.txt' />
      </reference>

    </references>
    <references title="Informative References">

      <reference anchor='CMC'>
        <front>
          <title>Certificate Management over CMS (CMC)</title>
          <author initials="J" surname="Schaad"></author>
          <author initials="M" surname="Myers"></author>
          <date year='2008' month='June' />
        </front>
        <seriesInfo name='RFC' value='5272' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc5272.txt' />
      </reference>

      <reference anchor='CMP'>
        <front>
          <title>Internet X.509 Public Key Infrastructure Certificate Management Protocol (CMP)</title>
          <author initials="C" surname="Adams"></author>
          <author initials="S" surname="Farrell"></author>
          <author initials="T" surname="Kause"></author>
          <author initials="T" surname="Mononen"></author>
          <date year='2005' month='September' />
        </front>
        <seriesInfo name='RFC' value='4210' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc4210.txt' />
      </reference>

      <reference anchor='HTTP-certstore'>
        <front>
          <title>Internet X.509 Public Key Infrastructure Operational Protocols: Certificate Store Access via HTTP</title>
          <author initials="P" surname="Gutmann"></author>
          <date year='2006' month='February' />
        </front>
        <seriesInfo name='RFC' value='4387' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc4387.txt' />
      </reference>

      <reference anchor='IKEv2'>
        <front>
          <title>Internet Key Exchange (IKEv2) Protocol</title>
<!--      <author initials="C" surname="Kaufman"></author> -->
          <author initials="D" surname="Alighieri"></author>
<!--      <date year='2005' month='December' /> -->
          <date year='1300' month='March' />
        </front>
        <seriesInfo name='RFC' value='4306' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc4306.txt' />
      </reference>

      <reference anchor='SMIME'>
        <front>
          <title>Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Message Specification</title>
          <author initials="B" surname="Ramsdell"></author>
          <author initials="S" surname="Turner"></author>
          <date year='2010' month='January' />
        </front>
        <seriesInfo name='RFC' value='5751' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc5751.txt' />
      </reference>

      <reference anchor='TLS'>
        <front>
          <title>The Transport Layer Security (TLS) Protocol Version 1.2</title>
          <author fullname="Tim Dierks" initials="T" surname="Dierks">
            <organization>Independent</organization>
          </author>
          <author fullname="Eric Rescorla" initials="E" surname="Rescorla">
            <organization>RTFM, Inc.</organization>
          </author>
          <date year='2008' month='August' />
        </front>
        <seriesInfo name='RFC' value='5246' />
        <format type='TXT' target='http://www.ietf.org/rfc/rfc5246.txt' />
      </reference>

    </references>
    <!-- ====================================================================== -->
    <section anchor="state-trans" title="SCEP State Transitions">
	  <t>

SCEP state transitions are indexed by the transactionID attribute. The design
goal is to ensure the synchronization between the CA and the requester under
various error situations.

	  </t>
	  <t>

Each enrolment transaction is uniquely associated with a transactionID
(carried in the transactionID signed attribute (see <xref
target="transactionID"/>).  Because the enrolment transaction could be
interrupted by various errors, including network connection errors or client
reboot, the SCEP client generates a fixed transaction identifier as specified
in <xref target="transactionID"/> which is included in the
PKCSReq/RenewalReq/UpdateReq.  If the CA returns a response of PENDING, the
requester will poll by periodically sending a CertPoll with the same
transaction identifier until either a response other than PENDING is obtained
or the configured maximum time has elapsed. This mechanism retains the same
transaction identifier throughout the enrolment transaction.

	  </t>
	  <t>

If the client times out or reboots, the client administrator will
start another transaction with the same key pair.  The second enrolment will
have the same transactionID.  At the server side, instead of accepting the
PKCSReq/RenewalReq/UpdateReq as a new request, it can respond as if another
CertPoll message had been sent with that transaction ID. The second
PKCSReq/RenewalReq/UpdateReq should be taken as a resynchronization message to
allow the process to resume as the same transaction.

	  </t>
	  <t>

The following gives several examples of client to CA transactions.

	  </t>
	  <t>

Client actions are indicated in the left column, CA actions are indicated in
the right column.  A blank action signifies that no message was received.

	  </t>
	  <t>

The first transaction, for example, would read like this:

	  </t>
	  <t>

"Client Sends PKCSReq message with transactionID 1 to the CA.  The CA signs
the certificate and constructs a CertRep Message containing the signed
certificate with a transaction ID 1.  The client receives the message and
installs the certificate locally."

	  </t>
	  <figure>
		<preamble>Successful Enrolment Case: no manual
				  authentication</preamble>
		<artwork><![CDATA[

PKCSReq (1)             ----------> CA Signs Cert
Client Installs Cert    <---------- CertRep (1) SIGNED CERT

		]]></artwork>
	  </figure>

	  <figure>
		<preamble>Successful Enrolment Case: manual authentication
				  required</preamble>
		<artwork><![CDATA[

PKCSReq (10)            ----------> Cert Request goes into Queue
Client Polls            <---------- CertRep (10) PENDING
CertPoll (10)           ----------> Still pending
Client Polls            <---------- CertRep (10) PENDING
CertPoll (10)           ----------> Still pending
Client Polls            <---------- CertRep (10) PENDING
CertPoll (10)           ----------> Still pending
Client Polls            <---------- CertRep (10) PENDING
CertPoll (10)           ----------> Cert has been signed
                        <---------- CertRep (10) SIGNED CERT
Client Installs Cert

		]]></artwork>
	  </figure>

	  <figure>
		<preamble>Resync Case 1 - CA Receives PKCSReq, sends PENDING,
				  eventually grants the certificate and returns SUCCESS, with
				  the certificate. The SUCCESS gets lost:</preamble>
		<artwork><![CDATA[

PKCSReq (3)           ----------> Cert Request goes into queue
                      <---------- CertRep (3) PENDING
CertPoll (3)          ----------> Still pending
                      <---------- CertRep (3) PENDING
CertPoll (3)          ----------> Cert has been signed
                        X-------- CertRep(3) SIGNED CERT
(Time Out)
PKCSReq (3)           ----------> Cert already granted
                      <---------- CertRep (3) SIGNED CERT
Client Installs Cert

		]]></artwork>
	  </figure>

	  <figure>
		<preamble>Resync Case 2 - CA Receives PKCSReq, sends PENDING, PENDING
				  reply gets lost:</preamble>
		<artwork><![CDATA[

PKCSReq (3)           ----------> Cert Request goes into queue
                        X-------- CertRep (3) PENDING
(Time Out)
PKCSReq (3)           ---------->
                      <---------- CertRep (3) PENDING
etc...

		]]></artwork>
	  </figure>

	  <figure>
		<preamble>Case when the Certificate is lost, the CA arbitrarily
				  refuses to sign a replacement (enforcing name-uniqueness)
				  until the original certificate has been revoked (there is no
				  change of name information):</preamble>
		<artwork><![CDATA[

PKCSReq (4)           ----------> CA Signs Cert
                      <---------- CertRep (4) SIGNED CERT
Client Installs Cert
(Client looses Cert)
PKCSReq (5)           ----------> There is already a valid cert with
                                  this DN.
                      <---------- CertRep (5) BAD REQUEST
                                  Admin Revokes
PKCSReq (5)           ----------> CA Signs Cert
                      <---------- CertRep (5) SIGNED CERT
Client Installs Cert

		]]></artwork>
	  </figure>

	  <figure>
		<preamble>CA certificate rollover case:</preamble>
		<artwork><![CDATA[

GetNextCACert         ---------->
                      <---------- New CA certificate

PKCSReq*              ----------> CA Signs certificate with NEW
                                  key
Client Stores Cert    <---------- CertRep - Certificate issued
for installation when             from NEW CA certificate and key
existing cert expires.            pair

		]]></artwork>
		<postamble>*enveloped for new CA cert and key pair.  The CA will use
				   the envelope to determine which key and certificate to use
				   to issue the client certificate.</postamble>
	  </figure>

	</section>
    <section anchor="background" title="Background Notes">
      <t>

This specification has spent more than fifteen years in the draft stage.  Its
original goal, provisioning IPsec routers with RSA certificates, has long
since changed to general device/embedded system/IoT use.  To fit this role,
extra features were bolted on in a haphazard manner through the addition of a
growing list of appendices and by inserting additional, often conflicting,
paragraphs in various locations in the body text.  Since existing features
were never updated as newer ones were added, the specification accumulated
large amounts of historical baggage over time.  If OpenPGP was described as "a
museum of 1990s crypto" then the SCEP draft was its graveyard.

      </t>
      <t>

About five years ago the specification, which even at that point had seen only
sporadic re-posts of the existing document, was more or less abandoned by its
original sponsors.  Due to its widespread use in large segments of the
industry, the specification was rebooted in 2015, cleaning up fifteen years of
accumulated cruft, fixing errors, clarifying ambiguities, and bringing the
algorithms and standards used into the current century (prior to the update,
the de-facto lowest-common denominator algorithms used for interoperability
were the forty-year-old single DES and broken MD5 hash algorithms).

      </t>
      <t>

Other changes include:

      </t>
      <t>

      <list style="symbols">

		<t>Resolved contradictions in the text, for example a requirement
		given as a MUST in one paragraph and a SHOULD in the next, a MUST NOT
		in one paragraph and a MAY a few paragraphs later, a SHOULD NOT
		contradicted later by a MAY, and so on.</t>

		<t>Merged several later fragmentary addenda placed in appendices (for
		example the handling of certificate renewal and update) with the body
		of the text.</t>

		<t>Updated the algorithms to ones dating from at least this
		century.</t>

		<t>Did the same for normative references to other standards.</t>

		<t>Corrected incorrect references to other standards, e.g.
		IssuerAndSerial -> IssuerAndSerialNumber.</t>

		<t>Corrected errors such as a statement that when both signature and
		encryption certificates existed, the signature certificate was used
		for encryption.</t>

		<t>Condensed redundant discussions of the same topic spread across
		multiple sections into a single location.  For example the description
		of intermediate CA handling previously existed in three different
		locations, with slightly different reqirements in each one.</t>

		<t>Relaxed some requirements that didn't serve any obvious purpose and
		that major implementations didn't seem to be enforcing.  For example
		the requirement that the self-signed certificate used with a request
		MUST contain a subject name that matched the one in the PKCS #10
		request was relaxed to a SHOULD because a number of implementations
		either ignored the issue entirely or at worst performed some minor
		action like creating a log entry after which they continued
		anyway.</t>

		<t>Clarified sections that were unclear or even made no sense, for
		example the requirement for a "hash on the public key [sic]" encoded
		as a PrintableString.</t>

		<t>Renamed "RA certificates" to "intermediate CA certificates".  The
		original document at some point added mention of RA certificates
		without specifying how the client was to determine that an RA was in
		use, how the RA operations were identified in the protocol, or how it
		was used.  It's unclear whether what was meant was a true RA or merely
		an intermediate CA, as opposed to the default practice of having
		certificates issued directly from a single root CA certificate. This
		update uses the term "intermediate CA certificates", since this seems
		to have been the original intent of the text.</t>

		<t>Clarified certificate renewal and update.  These represent a
		capability that was bolted onto the original protocol with (at best)
		vaguely-defined semantics, including a requirement by the server to
		guess whether a particular request was a renewal or not (updates were
		even more vaguely defined).  In response to developer feedback that
		they either avoided renewal/update entirely because of this
		uncertainty or hardcoded in particular behaviour on a per-server
		basis, this specification explicitly identifies renewal and update
		requests as such, and provides proper semantics for both.

		Note that this is still a work in progress due to the lack of clarity
		of the original spec in this area, see some of the questions inline
		with the text.</t>

		<t>Removed the discussion in the security considerations of revocation
		issues, since SCEP doesn't support revocation.</t>

      </list>

	  </t>
	</section>
    <!-- ====================================================================== -->
  </back>
</rfc>
