> For the complete documentation index, see [llms.txt](https://davidlebr1.gitbook.io/a-journey-in-infosec/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davidlebr1.gitbook.io/a-journey-in-infosec/blog/research/brother-printer-automatic-certificate-renewal.md).

# Brother Printer Automatic Certificate Renewal

![Certificate table list](/files/SKHpVHQNjiBV13jR5HkA)

### Description

I recently decided to build a home lab and started to put SSL Certificate on web application hosted internally. My certificate is generated using [ACME.SH](https://github.com/acmesh-official/acme.sh) by automatically generate a new valid certificate on \*.mydomain.com. This way, I can use the certificate on multiple web application.&#x20;

I was trying to find a way to automate the certificate renewal of my printer Brother MFC-L3750CDW and I didn't find any way to do it. Even online, there was no existing script from my research.&#x20;

So, I created this python script that will automatically renew the certificate by doing request on the web administrative portal.

The only prerequisites is to pass the following arguments:

* Protocol
* Hostname or ip of your printer
* Filepath of the certificate

### Phase of the script

1. Authenticate on the web portal
2. Delete any existing certificate
3. Upload the new certificate
4. Select the new uploaded certificate in the dropdown menu

### Generate the certificate

My certificate was generated this way by:

{% hint style="info" %}
I'm using Cloudflare for my domain management.&#x20;
{% endhint %}

```
#!/bin/bash
export CF_Token="";
export CF_Account_ID="";
export CF_Zone_ID="";
export CF_Key="";
export CF_Email="";

/root/.acme.sh/acme.sh --issue --dns dns_cf -d *.mydomain.com
```

Then, once the certificate is generated, I export it in the PKCS12 format because this is the only format accepted on the Brother portal.

```
openssl pkcs12 -export -out brother.pfx -inkey .acme.sh/*.mydomain.com/*.mydomain.com.key -in .acme.sh/*.mydomain.com/*.mydomain.com.cer
```

{% hint style="success" %}
**brother.pfx** is the file used to pass in the python script
{% endhint %}

### Running the script

Here is a preview of the execution of the script.&#x20;

![](/files/Rhjx7tbCUF59YnRx4rFM)

### Repository

The script can be accessed on the following Github repository.

{% embed url="<https://github.com/davidlebr1/brother-certificate-renewal>" %}
