آموزش نصب Let’s Encrypt Wildcard SSL در Ubuntu 20.04



وقتیکه میخواین وب سایت خودتون رو از با HTTPS اجرا کنین، باید مجوزهای SSL رو نصب کنید. میتونین certificates های مربوط رو خریداری کنین یا از Letry Encrypt رایگان استفاده کنین. Let’s Encrypt یک certificate authority (CA) است که با استفاده از فرآیند کاملاً خودکار ، ایجاد گواهی دستی ، اعتبار سنجی ، نصب و تمدید مجوزهای دستی SSL / TLS را ارائه می دهد. میتونین این certificates ها را روی وب سرور نصب کنید تا ترافیک سایت برای کاربران بصورت HTTPS باشه. بنابراین ، برای دریافت wildcard certificates رایگان و نصب اون در وب سرور، آموزش های این مقاله رو انجام بدین ، در زیر یاد می گیرید که چگونه با استفاده از Certbot یک گواهی wildcard SSL certificate برای دامنه خود تولید کنید.

 

نصب Let’s Encrypt Certbot Tool

قبل از ساخت wildcard certificates ، ابتدا می خواهید مطمئن شوید که certbot نصب شده و در حال اجرا است. برای نصب آن ، دستورات زیر را اجرا کنید:

sudo apt update
sudo apt-get install letsencrypt

دستورات فوق certbot tool و کلیه dependencies هایی را که اجازه tool function را دارند ، نصب می کنند.

 

ایجاد Let’s Encrypt Wildcard SSL Certificate

حالا که tool نصب شده ، میتونین اقدام به ایجاد certificates کنید. Let’s Encrypt روشهای زیادی برای به چالش کشیدن شما در تأیید اعتبار دامنه مورد نظر درخواستیتون، جهت ایجاد certificates SSL برای شما ارائه کرده است. یعنی اگر نتوانید اثبات کنید که مالک دامنه مورد نظر شما هستین ، قادر به تولید certificates نخواهید بود. با این حال ، برای wildcard certificates ، تنها روشی که Let’s Encrypt تایید کرده ، چالش DNS است که میتونیم از طریق استناد به preferred-challenges=dns flag از اون استفاده کنیم. بنابراین ، برای تولید یک wildcard cert برای دامنه * .example.com ، دستورات زیر را اجرا می کنید. همچنین باید ثبت نام bare domain را نیز درج کنید. (منظور از bare domain، دامنه های Bare رکوردهای DNS بدون www هستند ).

sudo certbot certonly --manual --preferred-challenges=dns --email
admin@example.com --server
https://acme-v02.api.letsencrypt.org/directory --agree-tos -d example.com -d *.example.com

 

دستورات کد بالارو در اینجا بررسی میکنیم:

certonly: گواهی را اخذ یا تمدید کنید ، اما نصب نکنید

–manual: دریافت گواهینامه های تعاملی

–preferred-challenges=dns: از dns برای تأیید مالکیت دامنه استفاده کنید

–server: نقطه پایانی مورد استفاده برای ایجاد گواهی را مشخص کنید

–agree-tos: با قوانین توافق شده سرور ACME موافقت کنید

-d: نام دامنه برای ارائه گواهی نامه برای

پس از اجرای دستور فوق ، Letry Encrypt متنی را برای اضافه کردن text record به ورودی DNS شما فراهم می کند. برای مثال

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None

-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: y
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com

-------------------------------------------------------------------------------
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
-------------------------------------------------------------------------------
(Y)es/(N)o: y

-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:

x4MrZ6y-JqFJQRmq_lGi9ReRQHPa1aTC9J2O7wDKzq8

Before continuing, verify the record is deployed.

به صفحه ارائه دهنده DNS خود بروید ( کنترل پنل دامنه برای تنظیم رکورد دامنه ، یا کنترل پنل سرور) و یک text record برای متن بالااضافه کنید و ذخیره کنید، مثلا یک رکورد به اسم _acme-challenge و آدرس TXT متن “x4MrZ6y-JqFJQRmq_lGi9ReRQHPa1aTC9J2O7wDKzq8” در DNS Zone دامنه اضافه.

چند دقیقه صبر کنید، برخی از ارائه دهندگان DNS برای تغییر و تنظیم DNS ممکن کمی طول بکشه تا تنظیمات اعمال بشه. پس از تغییرات فوق و رمزگذاری، Let’s encrypt میتونه اعتبار دامنه شمارو تایید کنه ، و باید پیام موفق بودن رو مشاهده کنین

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2020-01-09. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

آموزش نصب Let’s Encrypt Wildcard SSL در Ubuntu 20.04

اکنون گواهینامه wildcard تولید شده و آماده استفاده است. برای تأیید اعتبار certificate ، دستورات زیر را اجرا کنید:

sudo certbot certificates

باید مانند خروجی زیر، در صفحه شما هم کدهای مشابهی نمایش داده بشه:

Found the following certs:
  Certificate Name: example.com
    Domains: *.example.com
    Expiry Date: 2020-01-05 07:48:04+00:00 (VALID: 85 days)
    Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem

 

Let’s Encrypt’s certificates برای 90 روز اعتبار داره، اگه میخواین پروسه تمدید بصورت خودکار انجام بشه، برای انجام این کار ، crontab را باز کنید و ورودی زیر را اضافه کنید:

sudo crontab -e
0 1 * * * /usr/bin/certbot renew >> /var/log/letsencrypt/renew.log