# Enabling SSL

## Using an external SSL provider

{% hint style="info" %}
Available since `magento-scripts` 2.2.0
{% endhint %}

If you are using an external SSL provider, like Ngrok, you will need to use the following configuration:

{% code title="cma.js" %}

```javascript
module.export = {
    // other configuration
    ssl: {
        enabled: true,
        external_provider: true // <- enable this
    },
    storeDomains: {
        admin: 'a9a9-9999-99-999-99.ngrok-free.app' // <- put your domain here
    }
}
```

{% endcode %}

That is it! Just now we have enabled SSL in our application!\
With `storeDomains` you can expose any store in your instance.

Now to apply changes we need to run [start](https://docs.create-magento-app.com/getting-started/available-commands/start) command **without** [**-s option**](https://docs.create-magento-app.com/getting-started/available-commands/start#s-skip-setup).

{% hint style="warning" %}
You can run **only one** application with SSL enabled at the time because it will use port 443 which is the default port for SSL.
{% endhint %}

## Using local certificate

### 1. Get a certificate

You can use your existing certificate or create a new one using [mkcert](https://github.com/FiloSottile/mkcert) utility.\
Follow the installation [guide](https://github.com/FiloSottile/mkcert#installation) for your platform.&#x20;

After installation install mkcert certificate into your system by running the command below:

```bash
mkcert -install
```

Now we need to create a certificate.\
To create a certificate run command below:

```bash
> mkcert localhost 127.0.0.1

Created a new certificate valid for the following names 📜
 - "localhost"
 - "127.0.0.1"

The certificate is at "./localhost+1.pem" and the key at "./localhost+1-key.pem" ✅

It will expire on 13 May 2023 🗓
```

Now we have all files that we need for CMA config.

### 2. Setup CMA

Add to your `cma.js` file field `ssl` with the following object:

{% code title="cma.ks" %}

```javascript
module.export = {
    // other configuration
    ssl: {
        enabled: true,
        ssl_certificate: './localhost+1.pem',
        ssl_certificate_key: './localhost+1-key.pem'
    }
}
```

{% endcode %}

That is it! Just now we have enabled SSL in our application!\
Now to apply changes we need to run [start](https://docs.create-magento-app.com/getting-started/available-commands/start) command **without** [**-s option**](https://docs.create-magento-app.com/getting-started/available-commands/start#s-skip-setup).

{% hint style="warning" %}
You can run **only one** application with SSL enabled at the time because it will use port 443 which is the default port for SSL.
{% endhint %}
