Configure remote storage credentials and replace the self-signed certificate used by the origin server.

## Configuring credentials for direct remote storage access

### Format

The file is in the YAML format and located at `/etc/mediakind/mkp/charts/customer-values.yaml`. A specific script must be executed to apply the changes brought to the file that remain after a product update. If no value is specified or if a value is removed from the file, default values from installer are used.

Each entry contains the following elements:

- `url`: the base URL of a storage.
- `type`: the type of credential to be used for this base URL. It can be:
  - `user` for access with username and password
  - `s3` for access using AWS S3 object store credentials
  - `azureSasToken` for access using Blob Azure credential
  - `certificate` for HTTPS access

#### User credential

The entry should contain the following elements:

- `username`
- `password`

It can be used for FTP or SFTP access (`ftp://…` or `sftp://…`).

```yaml
credentials:
  [ {"type": "user", "url": "sftp://files.example.com/share1", "username": "<username>", "password": "<password>"} ]
```

#### Blob Azure credential

To configure the Azure authentication for your system, the entry in the credential file should contain the following elements:

- `url`: URL provided at the Blob storage creation.
- `type`: Type of credential to be used for this URL. It must be: `azureSasToken`.
- `sasToken`: Token provided at the Blob storage creation.

```yaml
credentials:
    [{"type" : "azureSasToken", "url" : "https://blob.example.com/container", "sasToken": "<sas-token>"} ]
```

#### AWS S3 object store credential

This credential corresponds to an AWS access key.

The entry should contain the following elements:

- `accessKeyId`: The ID of the access key
- `secretAccessKey`: The secret access key

```yaml
credentials:
  [{ "type": "s3", "url" : "https://storage.example.com", "accessKeyId": "<access-key-id>", "secretAccessKey": "<secret-access-key>"} ]
```

#### Certificate credentials

The entry should contain the following elements:

- `certificateFile`: to be defined in client\_crt\_certificate value
- `privateKeyFile`: to be defined in client\_key\_certificate value
- `privateKeyPassword`

Use section [Managing HTTPS certificates for the Origin Server](/traditional-products-and-appliances/components/packager/advanced-parameters#managing-https-certificates-for-the-origin-server) to define your certificate values

```yaml
credentials:
  [ {"type": "certificate", "url": "https://webdav.example.com/secure", "certificateFile": "/tmp/client-crt.pem", "privateKeyFile": "/tmp/client-key.pem", "privateKeyPassword": "<private-key-password>"} ]
```

#### Multiple credentials display

```yaml
credentials:
  [
  {"type": "user", "url": "sftp://files.example.com/share1", "username": "<username>", "password": "<password>"},
  {"type" : "azureSasToken", "url" : "https://blob.example.com/container", "sasToken": "<sas-token>"},
  { "type": "s3", "url" : "https://storage.example.com", "accessKeyId": "<access-key-id>", "secretAccessKey": "<secret-access-key>"}
  ]
```

### Deployment

This configuration file should be created by the user and needs to be deployed on every Packager server under the following path: /etc/mediakind/mkp/charts/customer-values.yaml.

Once the file `customer-values.yaml` is configured, the following script must be executed to apply the changes:

```shell
/etc/mediakind/mkp/charts/apply_customer_values.sh
```

### Example

When a job is created, it will parse this file to find the associated credentials of the file URL it needs to access.

For example, if the file contains the following credentials:

```yaml
credentials:
  [
  {"type" : "user", "url" : "sftp://files-a.example.com", "username": "<username>", "password": "<password>"},
  {"type" : "user", "url" : "sftp://files-b.example.com/share", "username": "<username>", "password": "<password>"}
  ]
```

If a job input file is `sftp://files-b.example.com/share/video.ts`, the second credential will be used: the input URL matches with the base URL of the second credential.

<blockquote data-callout="note"><strong>Note</strong><p>The job’s high-level logs identify the selected credentials configuration.</p></blockquote>

## Managing HTTPS certificates for the Origin Server

Packaging is configured with a self-signed certificate that is used to deliver contents using HTTPS.

This certificate must be replaced by a new certificate that is provided by a trusted authority on all the  servers of your headend. To apply dedicated certificates on your server:

1. Edit the file `customer-values.yaml`:

   ```shell
   vi /etc/mediakind/mkp/charts/customer-values.yaml
   ```

2. Update the credentials section of the file `/etc/mediakind/mkp/charts/customer-values.yaml` and copy in here the content of the `cert.pem` and `key.pem` files:

   ```yaml
   client_crt_certificate: |-
     <certificate PEM contents>
   client_key_certificate: |-
     <private key PEM contents>
   ```

   This operation requires inserting spaces at the beginning of each line, but you can automate it by running a script. Navigate to `/etc/mediakind/mkp/charts/`, copy your certificate files there, and execute the following commands:

   ```shell
   yq w -i -- customer-values.yaml "client_crt_certificate" "$(cat client-certificate.pem)"
   yq w -i -- customer-values.yaml "client_key_certificate" "$(cat client-key.pem)"
   ```

3. Define the path to the new certificates (by default defined in the `/tmp/` directory):

   ```yaml
   originserver:
     security:
       origin:
         certificate: /tmp/client-crt.pem
         privateKey: /tmp/client-key.pem
   ```

4. Execute the following script to apply the changes:

   ```shell
   /etc/mediakind/mkp/charts/apply_customer_values.sh
   ```
