# 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>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://davidlebr1.gitbook.io/a-journey-in-infosec/blog/research/brother-printer-automatic-certificate-renewal.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
