ÔõÑùÔÚLinuxЧÀÍÆ÷ÉÏÆôÓÃSSL¼ÓÃÜÒÔ±£»¤Web½Ó¿Ú£¿
ÔõÑùÔÚLinuxЧÀÍÆ÷ÉÏÆôÓÃSSL¼ÓÃÜÒÔ±£»¤Web½Ó¿Ú£¿
ͻ񻣼
ÔÚ½ñÌìµÄÊý×Ö»¯Ê±´ú£¬±£»¤WebЧÀÍÆ÷µÄÇå¾²ÐÔ±äµÃÖÁ¹ØÖ÷Òª¡£Ò»¸ö³£¼ûµÄ±£»¤ÒªÁìÊÇͨ¹ýSSL£¨Secure Socket Layer£©¼ÓÃÜÀ´±£»¤Web½Ó¿ÚµÄÊý¾Ý´«Êä¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxЧÀÍÆ÷ÉÏÆôÓÃSSL¼ÓÃÜ£¬ÒÔÈ·±£Web½Ó¿ÚµÄÇå¾²ÐÔ¡£ÎÒÃǽ«º¸ÇÌìÉúSSLÖ¤Êé¡¢ÉèÖÃWebЧÀÍÆ÷ÒÔʹÓÃSSL£¬²¢ÌÖÂÛһЩ³£¼ûÎÊÌâºÍ×î¼Ñʵ¼ù¡£
ÌìÉúSSLÖ¤Êé
ÌìÉúSSLÖ¤ÊéÊÇʹÓÃSSL¼ÓÃܵĵÚÒ»²½¡£ÓжàÖÖÒªÁì¿ÉÒÔÌìÉúSSLÖ¤Ê飬ÎÒÃǽ«ÏÈÈÝʹÓÃOpenSSLÌìÉú×ÔÊðÃûÖ¤ÊéµÄÒªÁì¡£
Ê×ÏÈ£¬×°ÖÃOpenSSL£º
$ sudo apt-get install openssl
µÇ¼ºó¸´ÖÆ
È»ºó£¬Ê¹ÓÃÒÔÏÂÏÂÁîÌìÉú˽ԿÎļþ£º
$ openssl genpkey -algorithm RSA -out private.key
µÇ¼ºó¸´ÖÆ
½ÓÏÂÀ´£¬ÌìÉú¹«Ô¿Ö¤ÊéÎļþ£º
$ openssl req -new -key private.key -out certificate.csr
µÇ¼ºó¸´ÖÆ
×îºó£¬×ÔÊðÃûÖ¤Ê飺
$ openssl x509 -req -days 365 -in certificate.csr -signkey private.key -out certificate.crt
µÇ¼ºó¸´ÖÆ
ÌìÉúµÄ˽ԿÎļþ£¨private.key£©ºÍÖ¤ÊéÎļþ£¨certificate.crt£©½«ÓÃÓÚÉèÖÃWebЧÀÍÆ÷¡£
ÉèÖÃWebЧÀÍÆ÷
ÔÚÕâÀÎÒÃǽ«ÒÔNginxΪÀýÀ´ÉèÖÃWebЧÀÍÆ÷ÒÔʹÓÃSSL¼ÓÃÜ¡£ÈôÊÇÄãʹÓÃÆäËûµÄWebЧÀÍÆ÷£¬Ö»ÐèÒª½«Ïà¹ØÉèÖÃÓ¦Óõ½ÄãµÄЧÀÍÆ÷¼´¿É¡£
Ê×ÏÈ£¬È·±£NginxÒѾװÖò¢ÔËÐС£È»ºó£¬±à¼NginxÉèÖÃÎļþ£¨Í¨³£Î»ÓÚ /etc/nginx/nginx.conf£©£º
$ sudo nano /etc/nginx/nginx.conf
µÇ¼ºó¸´ÖÆ
ÔÚÉèÖÃÎļþÖÐÕÒµ½server¿é£¬²¢ÔÚÆäÖÐÌí¼ÓÒÔÏÂÉèÖãº
server { listen 443; server_name example.com; ssl on; ssl_certificate /path/to/certificate.crt; ssl_certificate_key /path/to/private.key; # ÆäËûÉèÖÃÏî... }
µÇ¼ºó¸´ÖÆ
ÉÏÊöÉèÖÃÓÃÓÚÆôÓÃSSLºÍÖ¸¶¨SSLÖ¤ÊéµÄ·¾¶¡£È·±£½«Â·¾¶Ìæ»»³ÉÄãÏÖʵÌìÉúµÄÖ¤ÊéÎļþµÄ·¾¶¡£
µ±ÄãÍê³ÉÉèÖúó£¬ÉúÑIJ¢¹Ø±ÕÎļþ¡£È»ºó£¬ÖØÆôNginxÒÔʹÉèÖÃÉúЧ£º
$ sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
ÏÖÔÚ£¬ÄãµÄWebЧÀÍÆ÷½«Í¨¹ýSSL¼ÓÃÜ·½·¨ÔÚ443¶Ë¿ÚÉϼàÌýÀ´×Ô¿Í»§¶ËµÄÇëÇó¡£
³£¼ûÎÊÌâºÍ×î¼Ñʵ¼ù
ʹÓÃSSL¼ÓÃܺó£¬ÒÔÏÂÊÇһЩ³£¼ûÎÊÌâºÍ×î¼Ñʵ¼ù½¨Ò飺
3.1 Ö¤ÊéÑéÖ¤
ʹÓÃ×ÔÊðÃûÖ¤Êéʱ£¬ä¯ÀÀÆ÷»áÏÔʾ²»ÐÅÍеÄÖÒÑÔ¡£ÎªÁË×èÖ¹Õâ¸öÎÊÌ⣬Äã¿ÉÒÔ¹ºÖÃÒ»·ÝÓÉÊÜÐÅÍеÄCA½ÒÏþµÄÖ¤Êé¡£
3.2 °´ÆÚ¸üÐÂÖ¤Êé
SSLÖ¤Êéͨ³£ÓÐÒ»¸öµ½ÆÚÈÕÆÚ¡£ÎªÁ˼á³ÖÇå¾²ÐÔ£¬Ó¦°´ÆÚ¸üÐÂÖ¤Êé²¢ÖØÐÂÉèÖÃWebЧÀÍÆ÷¡£
3.3 Ç¿ÃÜÂë
È·±£½«Ë½Ô¿Îļþ±£»¤ÆðÀ´£¬²¢Ê¹ÓÃÇ¿ÃÜÂë±£»¤Ë½Ô¿Îļþ¡£
3.4 ½öÔÊÐí¼ÓÃÜÅþÁ¬
ΪÁËÇ¿ÖÆʹÓÃSSL¼ÓÃÜ£¬¿ÉÒÔÉèÖÃWebЧÀÍÆ÷Ö»½ÓÊܼÓÃܵÄÅþÁ¬£¬²¢½«·Ç¼ÓÃܵÄÇëÇóÖض¨Ïòµ½¼ÓÃÜÅþÁ¬¡£
×îºó£¬ÎÒÃÇÇ¿ÁÒ½¨ÒéÔĶÁÏà¹ØÎÄÏ׺Ͳο¼¹Ù·½ÎĵµÒÔÏàʶ¸ü¶à¹ØÓÚSSLÇå¾²µÄ×î¼Ñʵ¼ù¡£
½áÂÛ£º
ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÌÖÂÛÁËÔõÑùÔÚLinuxЧÀÍÆ÷ÉÏÆôÓÃSSL¼ÓÃÜÒÔ±£»¤Web½Ó¿Ú¡£ÎÒÃǺ¸ÇÁËÌìÉúSSLÖ¤Ê飬ÉèÖÃWebЧÀÍÆ÷ÒÔʹÓÃSSL£¬ÒÔ¼°Ò»Ð©³£¼ûÎÊÌâºÍ×î¼Ñʵ¼ù¡£Í¨¹ý×ñÕÕÕâЩ°ì·¨ºÍ×î¼Ñʵ¼ù£¬Äã¿ÉÒÔÔöÇ¿WebЧÀÍÆ÷µÄÇå¾²ÐÔ£¬±£»¤Óû§µÄÃô¸ÐÐÅÏ¢¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxЧÀÍÆ÷ÉÏÆôÓÃSSL¼ÓÃÜÒÔ±£»¤Web½Ó¿Ú£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡