0%

For the personal website like this site, if you want to secure your website, there is a free Let’s Encrypt SSL certificate you can choose.

On CentOS7 and the web server is Nginx, you can install Let’s Encrypt SSL certificate by the following steps:

Install acme.sh

Why choose this and not the official recommended certbot , because certbot need to install snapd first, and it is not easy to install on CentOS7. It will install a squashfs on your system, but on my CentOS7 after installed , system will not boot up. So I choose this acme.sh. to complete this installation.

1
curl https://get.acme.sh | sh -s [email protected] 

Create alias

1
alias acme.sh=~/.acme.sh/acme.sh

Issue a certificate

You can use the following command to issue a certificate, remember to change the domain name to your own domain name and webroot to your own webroot.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[[email protected] ~]# acme.sh --issue -d jichiduo.com -d www.jichiduo.com --webroot /var/www/jichiduo/
Sleep 10 and retry.
Using CA: https://acme.zerossl.com/v2/DV90
Create account key ok.
No EAB credentials found for ZeroSSL, let's get one
Registering account: https://acme.zerossl.com/v2/DV90
Registered
ACCOUNT_THUMBPRINT='mQBmCPjJMynTXXDo7WhlbtnhmJ3jN8zIUv3mf9P7DBk'
Creating domain key
The domain key is here: /root/.acme.sh/jichiduo.com/jichiduo.com.key
Multi domain='DNS:jichiduo.com,DNS:www.jichiduo.com'
Getting domain auth token for each domain
Getting webroot for domain='jichiduo.com'
Getting webroot for domain='www.jichiduo.com'
Verifying: jichiduo.com
Processing, The CA is processing your order, please just wait. (1/30)
Success
Verifying: www.jichiduo.com
Processing, The CA is processing your order, please just wait. (1/30)
Success
Verify finished, start to sign.
Lets finalize the order.
Le_OrderFinalize='https://acme.zerossl.com/v2/DV90/order/pBw-Xmw4uGoEhsQymi2E4g/finalize'
Order status is processing, lets sleep and retry.
Retry after: 15
Polling order status: https://acme.zerossl.com/v2/DV90/order/pBw-Xmw4uGoEhsQymi2E4g
Downloading cert.
Le_LinkCert='https://acme.zerossl.com/v2/DV90/cert/cHjNdPdEP8Ef27UeiPY65A'
Cert success.
-----BEGIN CERTIFICATE-----
certificate content
-----END CERTIFICATE-----
Your cert is in: /root/.acme.sh/jichiduo.com/jichiduo.com.cer
Your cert key is in: /root/.acme.sh/jichiduo.com/jichiduo.com.key
The intermediate CA cert is in: /root/.acme.sh/jichiduo.com/ca.cer
And the full chain certs is there: /root/.acme.sh/jichiduo.com/fullchain.cer
Read more »

This post is referenced from Connect to your Linux instance from Windows using PuTTY

Aws only provide one way to connect to Linux defaultly, it is through SSH by certificate, but the aws generated certificate is in OpenSSH format(in pem format), which is not supported by commonly used SSH client Putty(in ppk format). So we need to use PuttyGen to convert the certificate to PEM format.

Download Putty

You need to download the Putty MSI installer and install it.

Covert the certificate

You can generate the certificate by using the following steps:

  1. From the Start menu, choose All Programs, PuTTY, PuTTYgen.

  2. Under Type of key to generate, choose RSA. If your version of PuTTYgen does not include this option, choose SSH-2 RSA.

  3. Choose Load. By default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, choose the option to display files of all types.

  4. Select your .pem file for the key pair that you specified when you launched your instance and choose Open. PuTTYgen displays a notice that the .pem file was successfully imported. Choose OK.

  5. To save the key in the format that PuTTY can use, choose Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes.

  6. Specify the same name for the key that you used for the key pair (for example, my-key-pair) and choose Save. PuTTY automatically adds the .ppk file extension.

    Read more »

Unable to start sail

Newly installed Windows WSL2-Unbuntu21.04 and Docker Desktop 4.3.2 (72729) , after type the sail up command, I get the following error:

1
2
failed to solve with frontend dockerfile.v0: failed to create LLB definitin: failed to authorize: rpc error: code = Unknown desc = failed to fetch oauth token: Get "https://auth.docker.io/token?scope=repository%3Alibrary%2Fubuntu%3Apull&service=registry.docker.io": dial tcp: 52.55.168.20:443: i/o timeout
ERROR: Service 'laravel.test' failed to build: Build failed

Read more »

If you want to auto populate certain data to new sheet in Excel, you can use the following method. you can download the example file here.

Data table define

Init data

Asssume you have an excel file contains two sheets named “Sheet1” and “Sheet2”
All sheets have the same title row
id, name, price, quantity

we will fetch all quantity > 0 row to a new sheet named “Sheet3”

Read more »

The method for printing barcodes in Laravel is to use the Zebra ZPL. The Zebra ZPL is a standard for printing barcodes, you can simplely treat it as that you manually build some plain text and send it to the printer via socket.

Zebra ZPL

You can easily design your barcode by this online editor
http://staging.advanced-technology-group.com/

Or you can download a free tool to design your barcode, personal recommend this method
https://zpldesigner.com/

after that just copy your zpl code and treat it as your barcode template, later just replace the barcode data with your own data in code.

Sample code of Zebra ZPL

1
2
3
4
5
6
^XA
^CF0,100
^FO220,50^FDPantech-A02-06^FS
^BY4,3,70
^FO150,210^BCN,280,N^FDSLF-Pantech-A02-06^FS
^XZ

the printed out barcode is like this

Read more »