<?xml version="1.0" encoding="US-ASCII"?>
<rfc
    category="std"
    docName="draft-ietf-netconf-https-notif-15"
    submissionType="IETF"
    consensus="true"
    ipr="trust200902">
  <?rfc toc="yes"?>

  <front>
    <title abbrev="HTTPS Notification Transport">An HTTPS-based Transport for YANG Notifications</title>

    <author fullname="Mahesh Jethanandani" initials="M." surname="Jethanandani">
      <organization>Kloud Services</organization>
      <address>
        <email>mjethanandani@gmail.com</email>
      </address>
    </author>

    <author fullname="Kent Watsen" initials="K." surname="Watsen">
      <organization>Watsen Networks</organization>
      <address>
        <email>kent+ietf@watsen.net</email>
      </address>
    </author>

    <date/>
    <area>Operations</area>
    <workgroup>NETCONF</workgroup>
    <keyword>http</keyword>
    <keyword>yang</keyword>
    <keyword>notification</keyword>

    <abstract>
      <t>This document defines a protocol for sending asynchronous
      event notifications similar to notifications defined in RFC
      5277, but over HTTPS. YANG modules for configuring publishers
      are also defined.  Examples are provided illustrating how to
      configure various publishers.
      </t>
      <t>This document requires that the publisher is a "server" (e.g.,
        a NETCONF or RESTCONF server), but does not assume that the
        receiver is a server.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>This document defines a protocol for sending asynchronous
      event notifications similar to notifications defined in <xref
      target="RFC5277">NETCONF Event Notifications</xref>, but over
      HTTPS. Using HTTPS, which is a secure form of <xref
      target="RFC9110">HTTP Semantics</xref>, maximizes
      transport-level interoperability, while allowing for a variety
      of encoding options. The protocol supports <xref
      target="RFC9112">HTTP/1.1: Message Syntax and Routing</xref>
      and, <xref target="RFC9113">HTTP/2</xref>. While the payload
      does not change between these versions of HTTP and <xref
      target="RFC9114">HTTP/3</xref>, the underlying transport
      does. Since NETCONF does not support <xref
      target="RFC9000">QUIC: A UDP-Based Multiplexed and Secure
      Transport</xref>, support for <xref target="RFC9114">
      HTTP/3</xref>, is considered out of scope of this document.</t>
      
      <t>This document defines support for JSON and XML; future 
      efforts may define support for other encodings 
      (e.g., binary). This document requires that the publisher is a
      "server" (e.g., a NETCONF or RESTCONF server), but does not 
      assume that the receiver is a NETCONF or RESTCONF server. 
      It does expect the receiver to be an HTTPS server to receive
      the notifications.</t>

      <t>This document also defines two <xref target="RFC7950">YANG
      1.1</xref> modules that extend the data model defined in <xref
      target="RFC8639">Subscription to YANG Notifications</xref>,
      enabling the configuration of HTTPS-based receivers.</t>

      <t>An example module illustrating the configuration of a
      publisher not using the data model defined in RFC 8639 is also
      provided.</t>

      <t>Configured subscriptions enable a server (e.g., a NETCONF or
      RESTCONF server), acting as a publisher of notifications, to
      proactively push notifications to external receivers without the
      receivers needing to first connect to the server, as is the case
      with dynamic subscriptions.</t>

      <section title="Applicability Statement">
        <t>While the YANG modules have been defined as an augmentation of
        <xref target="RFC8639">Subscription to YANG Notifications</xref>, the
        notification method defined in this document MAY be used outside of
        <xref target="RFC8639">Subscription to YANG Notifications</xref> by
        using some of the definitions from this module along with the grouping
        defined in <xref
        target="I-D.ietf-netconf-http-client-server">Groupings for HTTP
        Clients and Servers</xref>. For an example on how that can be done,
        see Section A.2.</t>
      </section>

      <section title="Note to RFC Editor">
        <t>This document uses several placeholder values throughout the
          document. Please replace them as follows and remove this section
          before publication.</t>
        <t>RFC XXXX, where XXXX is the number assigned to this document at the
          time of publication.</t>
        <t>RFC YYYY, where YYYY is the number assigned to
        <xref target="I-D.ietf-netconf-http-client-server"/>.</t>
        <t>2024-02-01 with the actual date of the publication of this document.</t>
      </section>

      <section title="Abbreviations">
        <texttable>
          <ttcol>Acronym</ttcol>
          <ttcol>Expansion</ttcol>
          <c>HTTP</c>
          <c>Hypertext Transfer Protocol</c>
          <c>HTTPS</c>
          <c>Hypertext Transfer Protocol Secure</c>
	  <c>SSE</c>
	  <c>Server-Sent Events</c>
          <c>TCP</c>
          <c>Transmission Control Protocol</c>
          <c>TLS</c>
          <c>Transport Layer Security</c>
        </texttable>
      </section>

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

        <section title="Terms Imported from other RFCs">
          <t>The following terms are defined in <xref
          target="RFC8639">Subscription to YANG Notifications</xref>.
	  <list style="symbols">
	    <t>Publisher</t>
	    <t>Receiver</t>
	    <t>Subscribed Notifications</t>
          </list>
	  </t>
	  <t>The following term is defined in <xref
	  target="RFC8040">RESTCONF Protocol</xref>.
	  <list style="symbols">
	    <t>target resource</t>
	  </list>
	  </t>
        </section>
      </section>
      <section anchor="tree-diagram" title="Tree Diagram">
        <t>
	  The tree diagram for the YANG modules defined in this
	  document use annotations defined in <xref
	  target="RFC8340">YANG Tree Diagrams.</xref>.
	</t>
      </section>
    </section>

    <section title="Overview of Publisher to Receiver Interaction" anchor="overview">
      <t>The protocol consists of two HTTP-based target resources
      presented by the receiver.  These two resources share a common
      prefix that the publisher learns from a request it issues, as
      defined in section 3.2. If the data model in section 6.2 is
      used, this common prefix is defined by the "path" leaf in the
      "http-client-parameters" container.

      <list style="symbols">
	<t>"capabilities":  A target resource enabling the publisher
	to discover what optional capabilities a receiver supports.
	Publishers SHOULD query this target before sending any
	notifications or if ever an error occurs.</t>

	<t>"relay-notification":  A target resource enabling the publisher
	to send one or more notification to a receiver.  This document
	defines support for sending only one notification per message; a
	future effort MAY extend the protocol to send multiple
	notifications per message.</t>
      </list>
      </t>
      <t>The protocol is illustrated in the diagram below:</t>
      <t>
        <figure>
          <artwork><![CDATA[
          -------------                      --------------
          | Publisher |                      | Receiver   |
          -------------                      --------------

     Send HTTPS GET message    ------>
     to discover receiver's
     capabilities

                               <------    Send 200 (OK) containing
                                          capabilities supported
                                          by the receiver      


+-- For Each Notification ------------------ ---------------------+
|                                                                 |
|    Send HTTPS POST message   ------>                            |
|    with YANG defined                                            |
|    notification                                                 |
|                                                                 |
|                              <------    Send 204 (No Content)   |
+-----------------------------------------------------------------+]]></artwork>
        </figure>
      </t>
      <t>Note that, for RFC 8639 configured subscriptions, the very first
      notification must be the "subscription-started" notification.</t>
    </section>

    <section title="Discovering a Receiver's Capabilities">
      <section title="Applicability">
        <t>
	  For publishers using <xref target="RFC8639">Subscription to
	  YANG Notifications</xref>, dynamic discovery of a receiver's
	  supported encoding is necessary only when the
	  "/subscriptions/subscription/encoding" leaf is not
	  configured, per the "encoding" leaf's description statement
	  in the "ietf-subscribed-notification" module.
	</t>
	<t>
	  If the "encoding" leaf is not configured, and the publisher
	  wants to send a notification in a particular format, without
	  going through the setup operation of learning the receiver
	  capabilities, it can do so, but has to be prepared for the
	  case when it receives an error response, because the
	  receiver does not support the format sent by the publisher.
	</t>
      </section>
      <section title="Request">
        <t>
	  To learn the capabilities of a receiver, a publisher can
	  issue an HTTPS GET request to the "capabilities" resource
	  (see <xref target= "overview"/>) on the receiver with
	  "Accept" header set using the "application/xml" as defined
	  in <xref target="RFC7303">XML Media Types</xref>, and/or
	  "application/json" as defined in <xref
	  target="RFC8259">JSON</xref> media-types.
	</t>
      </section>
      <section title="Response">
        <t>The receiver responds with a "200 (OK)" message, having the
          "Content-Type" header set to either "application/xml" or
          "application/json" (which ever was selected), and containing
          in the response body a list of the receiver's capabilities
          encoded in the selected format.</t>
        <t>Even though a YANG module is not defined for this interaction,
          the response body MUST conform to the following YANG-modeled
          format:</t>
        <t>
          <figure>
            <artwork>container receiver-capabilities {
  description
    "A container for a list of capabilities supported by
     the receiver.";
  leaf-list receiver-capability {
    type "inet:uri";
    description
      "A capability supported by the receiver.  A partial list of
       capabilities is defined in the 'Capabilities for HTTPS
       Notification Receivers' registry (see RFC XXXX). Additional
       custom capabilities MAY be defined.";
  }
}
            </artwork>
          </figure>
        </t>
	<t>As it is possible that the receiver may return custom capability
	URIs, the publisher MUST ignore any capabilities that it does not
	recognize.
	</t>
      </section>
      <section title="Example">
        <t>The publisher can send the following request to learn the
        receiver capabilities. In this example, the "Accept" states
        that the publisher wants to receive the capabilities response
        in XML but, if not supported, then in JSON.</t>
        <t>
          <figure>
            <artwork><![CDATA[GET /some/path/capabilities HTTP/1.1
Host: example.com
Accept: application/xml, application/json;q=0.5]]></artwork>
          </figure>
        </t>
        <t>If the receiver is able to reply using "application/xml", and
        assuming it is able to receive JSON and XML encoded notifications,
	and it is able to process the RFC 8639 state machine, the
        response might look like this:</t>
        <t>
          <figure>
            <artwork><![CDATA[HTTP/1.1 200 OK
Date: Wed, 26 Feb 2020 20:33:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/xml

<receiver-capabilities>
  <receiver-capability>\
    urn:ietf:capability:https-notif-receiver:encoding:json\
  </receiver-capability>
  <receiver-capability>\
    urn:ietf:capability:https-notif-receiver:encoding:xml\
  </receiver-capability>
  <receiver-capability>\
    urn:ietf:capability:https-notif-receiver:sub-notif\
  </receiver-capability>
</receiver-capabilities>]]></artwork>
          </figure>
        </t>
        <t>If the receiver is unable to reply using "application/xml", the
        response might look like this:</t>
        <t>
          <figure>
            <artwork><![CDATA[HTTP/1.1 200 OK
Date: Wed, 26 Feb 2020 20:33:30 GMT
Server: example-server
Cache-Control: no-cache
Content-Type: application/json
Content-Length: nnn

{
   "receiver-capabilities": {
     "receiver-capability": [
       "urn:ietf:capability:https-notif-receiver:encoding:json",
       "urn:ietf:capability:https-notif-receiver:encoding:xml",
       "urn:ietf:capability:https-notif-receiver:sub-notif"
     ]
   }
}]]></artwork>
          </figure>
        </t>
      </section>
    </section>

    <section title="Sending Event Notifications"> 
      <section title="Request">
        <t>
	  The publisher sends an HTTP POST request to the
	  "relay-notification" resource (see <xref target=
	  "overview"/>) on the receiver with the "Content-Type" header
	  set to either "application/json" or "application/xml" and a
	  body containing the notification encoded using the specified
	  format.
	</t>
        <t>XML-encoded notifications are encoded using the format defined
          by <xref target="RFC5277">NETCONF Event Notifications</xref>
          for XML.</t>
        <t>JSON-encoded notifications are encoded the same as specified
          in Section 6.4 in <xref target="RFC8040">RESTCONF</xref> with
          the following deviations:
          <list style="symbols">
            <t>
	    The notifications do not contain the "data:" prefix used
	    by Server-Sent Events (SSE).
	    </t>
            <t>Instead of saying that, for JSON-encoding purposes, the
            module name for the "notification" element is
            "ietf-restconf", the module name will instead be
            "ietf-https-notif".</t>
          </list>
        </t>
      </section>
      <section title="Response">
        <t>
	  The response on success SHOULD be "204 (No Content)". In
	  case of corrupted or malformed event, the response SHOULD be
	  an appropriate HTTP error response.
	</t>
      </section>
      <section title="Example">
        <t>An XML-encoded notification might be sent as follows:</t>
        <t>
          <figure>
            <artwork><![CDATA[POST /some/path/relay-notification HTTP/1.1
Host: example.com
Content-Type: application/xml

<notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
  <eventTime>2019-03-22T12:35:00Z</eventTime>
  <event xmlns="https://example.com/example-mod">
    <event-class>fault</event-class>
    <reporting-entity>
      <card>Ethernet0</card>
    </reporting-entity>
    <severity>major</severity>
  </event>
</notification>]]></artwork>
          </figure>
        </t>
        <t>A JSON-encoded notification might be sent as follows:</t>
        <t><figure>
            <artwork><![CDATA[POST /some/path/relay-notification HTTP/1.1
Host: example.com
Content-Type: application/json

{
  "ietf-https-notif:notification": {
    "eventTime": "2013-12-21T00:01:00Z",
    "example-mod:event" : {
      "event-class" : "fault",
      "reporting-entity" : { "card" : "Ethernet0" },
      "severity" : "major"
    }
  }
}]]></artwork>
          </figure>
        </t>

        <t>And, in either case, the response on success might be as
        follows:</t>
        <t>
          <figure>
            <artwork><![CDATA[HTTP/1.1 204 No Content
Date: Wed, 26 Feb 2020 20:33:30 GMT
Server: example-server]]></artwork>
          </figure>
        </t>
      </section>
    </section>

    <section title='The "ietf-subscribed-notif-receivers" Module'>
      <section title="Data Model Overview">
        <t>This YANG module augments the "ietf-subscribed-notifications" module to
        define a choice of transport types that other modules such as the
        "ietf-https-notif-transport" module can use to define a transport specific
        receiver.</t>
        <t>
          <figure>
            <artwork><![CDATA[
module: ietf-subscribed-notif-receivers

  augment /sn:subscriptions:
    +--rw receiver-instances
       +--rw receiver-instance* [name]
          +--rw name    string
          +--rw (transport-type)
  augment /sn:subscriptions/sn:subscription/sn:receivers/sn:receiver:
    +--rw receiver-instance-ref?   leafref
]]></artwork>
          </figure>
        </t>
      </section>
      <section title="YANG Module">
        <t>The YANG module imports <xref target="RFC8639">Subscription to YANG Notifications</xref>.</t>
        <t>
          <figure>
            <artwork><![CDATA[
<CODE BEGINS> file "ietf-subscribed-notif-receivers@2024-02-01.yang"
module ietf-subscribed-notif-receivers {
  yang-version 1.1;
  namespace
    "urn:ietf:params:xml:ns:yang:ietf-subscribed-notif-receivers";
  prefix "snr";

  import ietf-subscribed-notifications {
    prefix sn;
    reference
      "RFC 8639: Subscription to YANG Notifications";
  }

  organization
    "IETF NETCONF Working Group";

  contact
    "WG Web:   <http://datatracker.ietf.org/wg/netconf>
     WG List:  <netconf@ietf.org>

     Authors: Mahesh Jethanandani (mjethanandani at gmail dot com)
              Kent Watsen (kent plus ietf at watsen dot net)";

  description
    "This YANG module is implemented by Publishers implementing
     the 'ietf-subscribed-notifications' module defined in RFC 8639.

     While this module is defined in RFC XXXX, which primarily 
     defines an HTTPS-based transport for notifications, this module
     is not HTTP-specific.  It is a generic extension that can be
     used by any 'notif' transport.

     This module defines two 'augment' statements.  One statement
     augments a 'container' statement called 'receiver-instances'
     into the top-level 'subscriptions' container.  The other 
     statement, called 'receiver-instance-ref', augments a 'leaf'
     statement into each 'receiver' that references one of the
     afore mentioned receiver instances.  This indirection enables
     multiple configured subscriptions to send notifications to
     the same receiver instance.

     Copyright (c) 2024 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.
     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Revised BSD
     License set forth in Section 4.c of the IETF Trust's Legal
     Provisions Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
     NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
     'MAY', and 'OPTIONAL' in this document are to be interpreted as
     described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
     they appear in all capitals, as shown here.";

  revision "2024-02-01" {
    description
      "Initial Version.";
    reference
      "RFC XXXX: An HTTPS-based Transport for YANG Notifications.";
  }

  augment "/sn:subscriptions" {
    container receiver-instances {
      description
        "A container for all instances of receivers.";

      list receiver-instance {
        key "name";
  
        leaf name {
          type string;
          description
            "An arbitrary but unique name for this receiver
             instance.";
        }
    
        choice transport-type {
          mandatory true;
          description
            "Choice of different types of transports used to
             send notifications.  The 'case' statements must
             be augmented in by other modules.";
        }
        description
          "A list of all receiver instances.";
      }
    }
    description
      "Augment the subscriptions container to define the
       transport type.";
  }

  augment
    "/sn:subscriptions/sn:subscription/sn:receivers/sn:receiver" {
    leaf receiver-instance-ref {
      type leafref {
        path "/sn:subscriptions/snr:receiver-instances/" +
             "snr:receiver-instance/snr:name";
      }
      description
        "Reference to a receiver instance.";
    }
    description
      "Augment the subscriptions container to define an optional
       reference to a receiver instance.";
  }
}
<CODE ENDS>
]]></artwork>
          </figure>
        </t>
      </section>
    </section>

    <section title='The "ietf-https-notif-transport" Module'>
      <section title="Data Model Overview">
        <t>This YANG module is a definition of a set of receivers that are
          interested in the notifications published by the publisher. The module
          contains the TCP, TLS and HTTPS parameters that are needed to
          communicate with the receiver. The module augments the
          "ietf-subscribed-notif-receivers" module to define a transport specific
          receiver. </t>
        <t>As mentioned earlier, it uses a POST method to deliver the
          notification. The "http-receiver/tls/http-client-parameters/path" leaf
          defines the path for the resource on the receiver, as defined by
          "path-absolute" in <xref target="RFC3986">URI Generic Syntax</xref>.
          The user-id used by <xref target="RFC8341">Network Configuration Access
          Control Model</xref>, is that of the receiver and is derived from the
          certificate presented by the receiver as part of "receiver-identity".</t>
        <t>An abridged tree diagram representing the module is shown
          below.</t>
        <t>
          <figure>
            <artwork><![CDATA[
module: ietf-https-notif-transport

  augment /sn:subscriptions/snr:receiver-instances
            /snr:receiver-instance/snr:transport-type:
    +--:(https)
       +--rw https-receiver
          +--rw (transport)
          |  +--:(tls) {tls-supported}?
          |     +--rw tls
          |        +--rw tcp-client-parameters
          |        |  +--rw remote-address    inet:host
          |        |  +--rw remote-port?      inet:port-number
          |        |  +--rw local-address?    inet:ip-address
          |        |  |       {local-binding-supported}?
          |        |  +--rw local-port?       inet:port-number
          |        |  |       {local-binding-supported}?
          |        |  +--rw proxy-server! {proxy-connect}?
          |        |  |     ...
          |        |  +--rw keepalives! {keepalives-supported}?
          |        |        ...
          |        +--rw tls-client-parameters
          |        |  +--rw client-identity!
          |        |  |     ...
          |        |  +--rw server-authentication
          |        |  |     ...
          |        |  +--rw hello-params {tlscmn:hello-params}?
          |        |  |     ...
          |        |  +--rw keepalives {tls-client-keepalives}?
          |        |        ...
          |        +--rw http-client-parameters
          |           +--rw client-identity!
          |           |     ...
          |           +--rw proxy-connect! {proxy-connect}?
          |           |     ...
          |           +--rw path               string
          +--rw receiver-identity {receiver-identity}?
             +--rw cert-maps
                +--rw cert-to-name* [id]
                   +--rw id             uint32
                   +--rw fingerprint    x509c2n:tls-fingerprint
                   +--rw map-type       identityref
                   +--rw name           string
]]></artwork>
          </figure>
        </t>
      </section>

      <section title="YANG module">
        <t>The YANG module imports 
        <xref target="RFC7407">A YANG Data Model for SNMP Configuration</xref>,
        <xref target="RFC8639">Subscription to YANG Notifications</xref>,
          <!--<xref target="I-D.ietf-subscribed-notif-receivers">An HTTPS-based Transport for Configured Subscriptions</xref>,-->
        and <xref target="I-D.ietf-netconf-http-client-server">YANG Groupings for HTTP Clients and HTTP Servers</xref>.</t>

        <t>The YANG module is shown below.</t>

        <t>
          <figure>
            <artwork><![CDATA[
<CODE BEGINS> file "ietf-https-notif-transport@2024-02-01.yang"
module ietf-https-notif-transport {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-https-notif-transport";
  prefix "hnt";

  import ietf-x509-cert-to-name {
    prefix x509c2n;
    reference
      "RFC 7407: YANG Data Model for SNMP Configuration.";
  }

  import ietf-subscribed-notifications {
    prefix sn;
    reference
      "RFC 8639: Subscription to YANG Notifications";
  }

  import ietf-subscribed-notif-receivers {
    prefix snr;
    reference
      "RFC XXXX: An HTTPS-based Transport for YANG Notifications.";
  }
  
  import ietf-http-client {
    prefix httpc;
    reference
      "RFC YYYY: YANG Groupings for HTTP Clients and HTTP Servers.";
  }

  organization
    "IETF NETCONF Working Group";

  contact
    "WG Web:   <http://datatracker.ietf.org/wg/netconf>
     WG List:  <netconf@ietf.org>

     Authors: Mahesh Jethanandani (mjethanandani at gmail dot com)
              Kent Watsen (kent plus ietf at watsen dot net)";

  description
    "This YANG module is implemented by Publishers that implement
     the 'ietf-subscribed-notifications' module defined in RFC 8639.

     This module augments a 'case' statement called 'https' into
     the 'choice' statement called 'transport-type' defined
     by the 'ietf-https-notif-transport' module defined in RFC XXXX.

     Copyright (c) 2024 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.
     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Revised BSD
     License set forth in Section 4.c of the IETF Trust's Legal
     Provisions Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL
     NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'NOT RECOMMENDED',
     'MAY', and 'OPTIONAL' in this document are to be interpreted as
     described in BCP 14 (RFC 2119) (RFC 8174) when, and only when,
     they appear in all capitals, as shown here.";

  revision "2024-02-01" {
    description
      "Initial Version.";
    reference
      "RFC XXXX: An HTTPS-based Transport for YANG Notifications.";
  }

  feature receiver-identity {
    description
      "Indicates that the server supports filtering notifications
       based on the receiver's identity derived from its TLS
       certificate.";
  }

  identity https {
    base sn:transport;
    description
      "HTTPS transport for notifications.";
  }

  grouping https-receiver-grouping {
    description
      "A grouping that may be used by other modules wishing to
       configure HTTPS-based notifications without using RFC 8639.";
    uses httpc:http-client-stack-grouping {
      refine "transport/tcp" {
        // create the logical impossibility of enabling the
        // "tcp" transport (i.e., "HTTP" without the 'S').
        if-feature "not httpc:tcp-supported";
      }
      augment "transport/tls/tls/http-client-parameters" {
        leaf path {
          type string;
          mandatory true;
          description
            "A path to the target resources.  Under this
             path the receiver must support both the 'capabilities'
             and 'relay-notification' resource targets, as described
             in RFC XXXX.";
        }
        description
          "Augmentation to add a receiver-specific path for the
           'capabilities' and 'relay-notification' resources.";
      }
    }
    container receiver-identity {
      if-feature receiver-identity;
      description
        "Maps the receiver's TLS certificate to a local identity
         enabling access control to be applied to filter out
         notifications that the receiver may not be authorized
         to view.";
      container cert-maps {
        uses x509c2n:cert-to-name;
        description
          "The cert-maps container is used by a TLS-based HTTP
           server to map the HTTPS client's presented X.509
           certificate to a 'local' username. Specifically, the
           'name' field within the module is used along with
           'specified' identity to perform the match. If no
           matching and valid cert-to-name list entry is found,
           the publisher MUST close the connection, and MUST
           NOT send any notifications over it.";
        reference
          "RFC 7407: A YANG Data Model for SNMP Configuration.";
      }
    }
  }

  augment "/sn:subscriptions/snr:receiver-instances/" +
          "snr:receiver-instance/snr:transport-type" {
    case https {
      container https-receiver {
        description
          "The HTTPS receiver to send notifications to.";
        uses https-receiver-grouping;
      }
    }
    description
      "Augment the transport-type choice to include the 'https'
       transport.";
  }
}
<CODE ENDS>
]]></artwork>
          </figure>
        </t>
      </section>
    </section>

    <section title="Security Considerations">
      <t>The YANG modules specified in this document define a schema
      for data that is designed to be accessed via network management
      protocols such as <xref target="RFC6241">NETCONF</xref> or <xref
      target="RFC8040">RESTCONF</xref>. The lowest NETCONF layer is
      the secure transport layer, and the mandatory-to-implement
      secure transport is <xref target="RFC6242">Secure Shell
      (SSH)</xref>. The lowest RESTCONF layer is HTTPS, and the
      mandatory-to-implement secure transport is <xref
      target="RFC8446">TLS</xref>. The <xref target="RFC8341">NETCONF
      Access Control Model (NACM) </xref> provides the means to
      restrict access for particular NETCONF or RESTCONF users to a
      preconfigured subset of all available NETCONF or RESTCONF
      protocol operations and content.</t>

      <t>The YANG modules in this document make use of groupings that
      are defined in <xref
      target="I-D.ietf-netconf-http-client-server">YANG Groupings for
      HTTP Clients and HTTP Servers</xref>, <xref
      target="I-D.ietf-netconf-tls-client-server">YANG Groupings for
      TLS Clients and TLS Servers</xref>, and <xref target="RFC7407">A
      YANG Data Model for SNMP Configuration</xref>. Please see the
      Security Considerations section of those documents for
      considerations related to sensitivity and vulnerability of the
      data nodes defined in them. Additionally, the parameters defined
      in the tls-client-grouping in the ietf-tls-client module should
      follow the recommendations specified in <xref
      target="RFC9325">Recommendations for Secure Use of Transport
      Layer Security (TLS) and Datagram Transport Layer Security
      (DTLS).</xref></t>

      <t>There are a number of data nodes defined in the YANG modules
      that are writable/creatable/deletable (i.e., config true, which
      is the default).  These data nodes may be considered sensitive
      or vulnerable in some network environments. Write operations
      (e.g., edit-config) to these data nodes without proper
      protection can have a negative effect on network
      operations. These are the subtrees and data nodes and their
      sensitivity/vulnerability:</t>

      <t>
        <list style="symbols">
          <t>The "path" node in "ietf-subscribed-notif-receivers"
          module can be modified by a malicious user to point to an
          invalid URI. Worse still, it could point the URI of their
          choosing, exploit the vulnerable client, and if redirects
          are followed to the same URI, track its usage.</t>
        </list>
	<list>
	  <t>The container "receiver-identity" contains nodes like
	  "cert-maps" that are used by the HTTP server to map to the
	  HTTPS client's certificate to a 'local' username. An
	  unintended modification of these nodes will result in new
	  connection requests be denied.</t>
	</list>
      </t>

      <t>Some of the readable data nodes in the YANG modules may be
      considered sensitive or vulnerable in some network
      environments. It is thus important to control read access (e.g.,
      via get, get-config, or notification) to these data nodes. The
      model does not define any readable subtrees and data nodes that
      are particularly sensitive or vulnerable.</t>

      <t>Some of the RPC operations in the YANG modules may be
      considered sensitive or vulnerable in some network
      environments. It is thus important to control access to these
      operations. The model does not define any RPC operations.</t>
    </section>

    <section title="IANA Considerations">
      <section title='The "IETF XML" Registry'>
        <t>This document registers two URIs in the "ns" subregistry
          of the "IETF XML" registry <xref target="RFC3688"/>.  Following
          the format in <xref target="RFC3688"/>, the following
          registrations are requested:</t>
        <t>
          <figure>
            <artwork>
URI: urn:ietf:params:xml:ns:yang:ietf-subscribed-notif-receivers
Registrant Contact: The IESG
XML: N/A, the requested URI is an XML namespace.

URI: urn:ietf:params:xml:ns:yang:ietf-https-notif-transport
Registrant Contact: The IESG
XML: N/A, the requested URI is an XML namespace.
</artwork>
          </figure>
        </t>
      </section>
      <section title='The "YANG Module Names" Registry'>
        <t>This document registers two YANG modules in the
          "YANG Module Names" registry <xref target="RFC6020"/>.
          Following the format in <xref target="RFC6020"/>, the
          following registrations are requested:</t>
        <t>
          <figure>
            <artwork>
name:      ietf-subscribed-notif-receivers
namespace: urn:ietf:params:xml:ns:yang:ietf-subscribed-notif-receivers
prefix:    snr
reference: RFC XXXX

name:      ietf-https-notif-transport
namespace: urn:ietf:params:xml:ns:yang:ietf-https-notif-transport
prefix:    hnt
reference: RFC XXXX
</artwork>
          </figure>
        </t>
      </section>

      <section title="Registration of 'yang-notif' URN Sub-namespace">
        <t>
        This document requests that IANA register a new URN Sub-namespace within the
         "IETF URN Sub-namespace for Registered Protocol Parameter Identifiers"
         registry defined in <xref target="RFC3553"/>.
        </t>
        <t>
          <figure>
            <artwork>
Registry Name: yang-notif
Specification: RFC XXXX
Repository: "YANG Notifications" registry
            </artwork>
          </figure>
        </t>
      </section>
      <section title="Registration of 'https' URN Sub-namespace">
        <t>
        This document requests that IANA register a new URN Sub-namespace within the
         "YANG Notifications" registry group defined in <xref target="RFC3553"/>.
        </t>
        <t>
          <figure>
            <artwork>
Registry Name: https-capability
Specification: RFC XXXX
Repository: "Capabilities for HTTPS Notification Receivers" registry
            </artwork>
          </figure>
        </t>
        <t>The following note shall be at the top of the registry:</t>
        <t>
          <figure>
            <artwork>This registry defines capabilities that can be
supported by HTTPS-based notification receivers.
            </artwork>
          </figure>
        </t>
        <t>The fields for each registry are:
          <list style="symbols">
            <t>URN
              <list style="symbols">
                <t>The name of the URN (required).</t>
                <t>The URN must conform to the syntax described by <xref target="RFC8141"/>.</t>
                <t>The URN must begin with the string "urn:ietf:params:yang-notif:https-capability".</t>
              </list>
            </t>
            <t>Reference
              <list style="symbols">
                <t>The RFC that defined the URN.</t>
                <t>The RFC must be in the form "RFC &lt;Number&gt;: &lt;Title&gt;.</t>
              </list>
            </t>
            <t>Description
              <list style="symbols">
                <t>An arbitrary description of the capability.</t>
                <t>The description should be no more than a few sentences.</t>
                <t>The description is to be in English, but may contain
                  UTF-8 characters as may be needed in some cases.</t>
              </list>
            </t>
          </list>
        </t>

        <t>
	  The update policy is "RFC Required".
        </t>
        <t>Following is the initial assignment for this registry:</t>
        <t>
          <figure>
            <artwork>
Record:
   URN:         urn:ietf:params:yang-notif:https-capability:encoding:json
   Reference:   RFC XXXX:An HTTPS-based Transport for YANG Notifications
   Description: Identifies support for JSON-encoded notifications.

Record:
   URN:         urn:ietf:params:yang-notif:https-capability:encoding:xml
   Reference:   RFC XXXX:An HTTPS-based Transport for YANG Notifications
   Description: Identifies support for XML-encoded notifications.

Record:
   URN:         urn:ietf:params:yang-notif:https-capability:sub-notif
   Reference:   RFC XXXX:An HTTPS-based Transport for YANG Notifications
   Description: Identifies support for state machine described in
                RFC 8639, enabling the publisher to send, e.g., the
                "subscription-started" notification.
            </artwork>
          </figure>
        </t>
      </section>
    </section>
  </middle>

  <back>
    <references title="Normative references">
      <?rfc include='reference.RFC.2119.xml'?>
      <?rfc include='reference.RFC.3553.xml'?>
      <?rfc include='reference.RFC.3688.xml'?>
      <?rfc include='reference.RFC.3986.xml'?>
      <?rfc include='reference.RFC.5277.xml'?>
      <?rfc include='reference.RFC.6020.xml'?>
      <?rfc include='reference.RFC.6241.xml'?>
      <?rfc include='reference.RFC.6242.xml'?>
      <?rfc include='reference.RFC.7303.xml'?>
      <?rfc include='reference.RFC.7407.xml'?>
      <?rfc include='reference.RFC.7950.xml'?>
      <?rfc include='reference.RFC.8040.xml'?>
      <?rfc include='reference.RFC.8174.xml'?>
      <?rfc include='reference.RFC.8259.xml'?>
      <?rfc include='reference.RFC.8340.xml'?>
      <?rfc include='reference.RFC.8341.xml'?>
      <?rfc include='reference.RFC.8446.xml'?>
      <?rfc include='reference.RFC.8639.xml'?>
      <?rfc include='reference.RFC.9000.xml'?>
      <?rfc include='reference.RFC.9110.xml'?>
      <?rfc include='reference.RFC.9112.xml'?>
      <?rfc include='reference.RFC.9113.xml'?>
      <?rfc include='reference.RFC.9114.xml'?>
      <?rfc include='reference.RFC.9325.xml'?>
      <?rfc include='reference.I-D.ietf-netconf-http-client-server.xml'?>
      <?rfc include='reference.I-D.ietf-netconf-tls-client-server.xml'?>
    </references>
    <references title="Informative references">
      <?rfc include='reference.RFC.8141.xml'?>
    </references>

    <section title="Configuration Examples">
      <t>This non-normative section shows two examples for how the "ietf-https-notif-transport"
        module can be used to configure a publisher to send notifications to
        a receiver.</t>

      <t>In both examples, the publisher, being an HTTPS client, is
      configured to send notifications to a receiver.</t>

      <section title="Using Subscribed Notifications (RFC 8639)">
        <t>This example shows how an <xref target="RFC8639">RFC 8639</xref>
          based publisher can be configured to send notifications to a
          receiver.</t>
        <t>
          <figure>
            <artwork><![CDATA[
=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0" encoding="UTF-8"?>
<subscriptions
    xmlns="urn:ietf:params:xml:ns:yang:ietf-subscribed-notifications\
">
  <receiver-instances
      xmlns="urn:ietf:params:xml:ns:yang:ietf-subscribed-notif-recei\
vers">
    <receiver-instance>
      <name>global-receiver-def</name>
      <https-receiver
          xmlns="urn:ietf:params:xml:ns:yang:ietf-https-notif-transp\
ort"
          xmlns:x509c2n="urn:ietf:params:xml:ns:yang:ietf-x509-cert-\
to-name">
        <tls>
          <tcp-client-parameters>
            <remote-address>receiver.example.com</remote-address>
            <remote-port>443</remote-port>
          </tcp-client-parameters>
          <tls-client-parameters>
            <server-authentication>
              <ca-certs>
                <local-definition>
                  <certificate>
                    <name>Server Cert Issuer #1</name>
                    <cert-data>base64encodedvalue==</cert-data>
                  </certificate>
                </local-definition>
              </ca-certs>
            </server-authentication>
          </tls-client-parameters>
          <http-client-parameters>
            <client-identity>
              <basic>
                <user-id>my-name</user-id>
                <cleartext-password>my-password</cleartext-password>
              </basic>
            </client-identity>
            <path
                xmlns="urn:ietf:params:xml:ns:yang:ietf-https-notif-\
transport">/some/path</path>
          </http-client-parameters>
        </tls>
        <receiver-identity>
          <cert-maps>
            <cert-to-name>
              <id>1</id>
              <fingerprint>11:0A:05:11:00</fingerprint>
              <map-type>x509c2n:san-any</map-type>
            </cert-to-name>
          </cert-maps>
        </receiver-identity>
      </https-receiver>
    </receiver-instance>
  </receiver-instances>
  <subscription>
    <id>6666</id>
    <transport xmlns:ph="urn:ietf:params:xml:ns:yang:ietf-https-noti\
f-transport">ph:https</transport>
    <stream-subtree-filter>
      <some-subtree-filter/>
    </stream-subtree-filter>
    <stream>some-stream</stream>
    <receivers>
      <receiver>
        <name>subscription-specific-receiver-def</name>
        <receiver-instance-ref xmlns="urn:ietf:params:xml:ns:yang:ie\
tf-subscribed-notif-receivers">global-receiver-def</receiver-instanc\
e-ref>
      </receiver>
    </receivers>
  </subscription>
</subscriptions>
<truststore xmlns="urn:ietf:params:xml:ns:yang:ietf-truststore">
  <certificate-bags>
    <certificate-bag>
      <name>explicitly-trusted-server-ca-certs</name>
      <description>
        Trust anchors (i.e. CA certs) that are used to
        authenticate connections to receivers.  Receivers
        are authenticated if their certificate has a chain
        of trust to one of these CA certificates.
        certificates.
      </description>
      <certificate>
        <name>ca.example.com</name>
        <cert-data>base64encodedvalue==</cert-data>
      </certificate>
      <certificate>
        <name>Fred Flintstone</name>
        <cert-data>base64encodedvalue==</cert-data>
      </certificate>
    </certificate-bag>
  </certificate-bags>
</truststore>
]]></artwork>
          </figure>
        </t>
      </section>

      <section title="Not Using Subscribed Notifications">
        <t>In the case that it is desired to use HTTPS-based
        notifications outside of Subscribed Notifications, an
        application-specific module would need to define the
        configuration for sending the notification.</t>
        <t>Following is an example module.  Note that the module
        "uses" the "https-receiver-grouping" grouping from the
        "ietf-https-notif-transport" module.</t>
        <t>
          <figure>
            <artwork><![CDATA[
module example-custom-module {
  yang-version 1.1;
  namespace "http://example.com/example-custom-module";
  prefix "custom";

  import ietf-https-notif-transport {
    prefix "hnt";
    reference
      "RFC XXXX:
        An HTTPS-based Transport for Configured Subscriptions";
  }

  organization
    "Example, Inc.";

  contact
    "Support at example.com";
  
  description
    "Example of module not using Subscribed Notifications module.";
  
  revision "2024-02-01" {
    description
      "Initial Version.";
    reference
      "RFC XXXX: An HTTPS-based Transport for YANG Notifications.";
  }

  container example-module {
    description
      "Example of using HTTPS notif without having to
       implement Subscribed Notifications.";

    container https-receivers {
      description
        "A container of all HTTPS notif receivers.";
      list https-receiver {
       key "name";
        description
          "A list of HTTPS notif receivers.";
       leaf name {
         type string;
         description
           "A unique name for the https notif receiver.";
       }
        uses hnt:https-receiver-grouping;
      }
    }
  }
}
]]></artwork>
          </figure>
        </t>
        <t>Following is what the corresponding configuration looks like:</t>
        <t>
          <figure>
            <artwork><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<example-module xmlns="http://example.com/example-custom-module">
  <https-receivers>
    <https-receiver>
      <name>foo</name>
      <tls>
        <tcp-client-parameters>
          <remote-address>receiver.example.com</remote-address>
          <remote-port>443</remote-port>
        </tcp-client-parameters>
        <tls-client-parameters>
          <server-authentication>
            <ca-certs>
              <local-definition>
                <certificate>
                  <name>Server Cert Issuer #1</name>
                  <cert-data>base64encodedvalue==</cert-data>
                </certificate>
              </local-definition>
            </ca-certs>
          </server-authentication>
        </tls-client-parameters>
        <http-client-parameters>
          <client-identity>
            <basic>
              <user-id>my-name</user-id>
              <cleartext-password>my-password</cleartext-password>
            </basic>
          </client-identity>
          <path>/some/path</path>
        </http-client-parameters>
      </tls>
    </https-receiver>
  </https-receivers>
</example-module>
]]></artwork>
          </figure>
        </t>
      </section>
    </section>

    <section title="Acknowledgements" numbered="no">
      <t>The authors would like to thank for following for
      lively discussions on list and in the halls (ordered
      by first name):
        Eric Voit,
        Henning Rogge,
        Martin Bjorklund,
        Reshad Rahman,
        and Rob Wilton.
      </t>
      <t>In addition, the authors would also like to thank Quifang Ma
      for providing thoughtful comments as part of shepherd
      writeup.</t>
    </section>
  </back>
</rfc>
