..
..
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. You may obtain a copy of the License at
..
..     http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS,
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.. See the License for the specific language governing permissions and
.. limitations under the License.
..

.. _to-api-v1-deliveryservices-hostname-name-sslkeys:

**********************************************
``deliveryservices/hostname/{{name}}/sslkeys``
**********************************************
.. deprecated:: ATCv4
	This endpoint is deprecated. Please use :ref:`to-api-v1-deliveryservices-xmlid-xmlid-sslkeys` instead.

``GET``
=======
:Auth. Required: Yes
:Roles Required: "admin"
:Response Type:  Object

Request Structure
-----------------
.. table:: Request Path Parameters

	+------+--------------------------------------------------------------------------------------------------------------------+
	| Name | Description                                                                                                        |
	+======+====================================================================================================================+
	| name | The hostname of the desired :term:`Delivery Service` - has the form ``{{routing name}}.{{xml_id}}.{{CDN domain}}`` |
	+------+--------------------------------------------------------------------------------------------------------------------+

.. table:: Request Query Parameters

	+---------+----------+---------------------------------------------------------+
	|   Name  | Required |          Description                                    |
	+=========+==========+=========================================================+
	| version | no       | The version number of SSL keys which shall be retrieved |
	+---------+----------+---------------------------------------------------------+

.. code-block:: http
	:caption: Request Example

	GET /api/1.4/deliveryservices/hostname/video.demo1.mycdn.ciab.test/sslkeys HTTP/1.1
	Host: trafficops.infra.ciab.test
	User-Agent: curl/7.47.0
	Accept: */*
	Cookie: mojolicious=...

Response Structure
------------------
:businessUnit: An optional field which, if present, contains the business unit entered by the user when generating the SSL certificate\ [#optional]_
:certificate:  An object containing the actual generated key, certificate, and signature of the SSL keys

	:crt: Base 64-encoded (or not if the ``decode`` query parameter was given and ``true``) certificate for the :term:`Delivery Service` identified by ``deliveryservice``
	:csr: Base 64-encoded (or not if the ``decode`` query parameter was given and ``true``) csr file for the :term:`Delivery Service` identified by ``deliveryservice``
	:key: Base 64-encoded (or not if the ``decode`` query parameter was given and ``true``) private key for the :term:`Delivery Service` identified by ``deliveryservice``

	.. caution:: There's almost certainly no good reason to request the private key! Even when "base 64-encoded" do not let **ANYONE** see this who would be unable to request it themselves!

:cdn:             The CDN of the :term:`Delivery Service` for which the certs were generated
:city:            An optional field which, if present, contains the city entered by the user when generating the SSL certificate\ [#optional]_
:country:         An optional field which, if present, contains the country entered by the user when generating the SSL certificate\ [#optional]_
:deliveryservice: The string that is :ref:`ds-xmlid` of the :term:`Delivery Service` for which the certificate was generated
:hostname:        The hostname generated by Traffic Ops that is used as the common name when generating the certificate - this will be an :abbr:`FQDN (Fully Qualified Domain Name)` for DNS :term:`Delivery Services` and a wildcard URL for HTTP :term:`Delivery Services`
:organization:    An optional field which, if present, contains the organization entered by the user when generating certificate\ [#optional]_
:state:           An optional field which, if present, contains the state entered by the user when generating certificate\ [#optional]_
:version:         An integer that defines the "version" of the key - which may be thought of as the sequential generation; that is, the higher the number the more recent the key
:expiration:      The expiration date of the certificate for the :term:`Delivery Service` in :rfc:`3339` format

	.. versionadded:: 1.5

.. code-block:: http
	:caption: Response Example

	HTTP/1.1 200 OK
	Access-Control-Allow-Credentials: true
	Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie
	Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
	Access-Control-Allow-Origin: *
	Content-Type: application/json
	Set-Cookie: mojolicious=...; Path=/; Expires=Mon, 18 Nov 2019 17:40:54 GMT; Max-Age=3600; HttpOnly
	Whole-Content-Sha512: eXZMeGFYSJgjg/rC1JtHpqMHNEvxGZwbKCXs5mOFF+oU74UXmRKl/2KF+kLyNfHGTScEZ07m/qqpwDLgvlGOEg==
	X-Server-Name: traffic_ops_golang/
	Date: Thu, 31 Jan 2019 19:44:21 GMT
	Transfer-Encoding: chunked

	{ "response": {
		"cdn": "CDN-in-a-Box",
		"deliveryservice": "demo1",
		"hostname": "*.demo1.mycdn.ciab.test",
		"key": "demo1",
		"version": 1,
		"certificate": {
			"crt": "...",
			"key": "...",
			"csr": "..."
		},
		"expiration": "2020-08-18T13:53:06Z"
	},
	"alerts": [
		{
			"text": "This endpoint is deprecated, please use '/deliveryservices/xmlId/{{XMLID}}/sslkeys' instead",
			"level": "warning"
		}
	]}

.. note:: The response example uses abbreviated values for the ``crt``, ``key``, and ``csr``, as these will generally be very large, base64-encoded SSL keys and certificates. Note that in general the output of this request should **not** be made available, as the ``key`` field contains the *private* SSL key corresponding to the certificate.


.. [#optional] These optional fields will be present in the response if and only if they were specified during key generation; they are optional during key generation and thus cannot be guaranteed to exist or not exist.
