You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
6.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. # le: means simp`Le`
  2. Simplest shell script for LetsEncrypt free Certificate client
  3. Simple and Powerful, you only need 3 minutes to learn.
  4. Pure written in bash, no dependencies to python, acme-tiny or LetsEncrypt official client.
  5. Just one script, to issue, renew your certificates automatically.
  6. Probably it's the smallest&easiest&smartest shell script to automatically issue & renew the free certificates from LetsEncrypt.
  7. Do NOT require to be `root/sudoer`.
  8. #Tested OS
  9. 1. Ubuntu/Debian.
  10. 2. CentOS 5, 6, 7
  11. 3. Windows (cygwin with curl, openssl and crontab included)
  12. 4. FreeBSD with bash
  13. 5. pfsense with bash and curl
  14. 6. openSUSE 13
  15. 7. Alpine Linux (with bash, curl. https://github.com/Neilpang/le/issues/94)
  16. 8. Archlinux
  17. 9. fedora 21, 22, 23
  18. If anyone want to test le on your system, you can simply run our test project: https://github.com/Neilpang/letest
  19. #Supported Mode
  20. 1. Webroot mode
  21. 2. Standalone mode
  22. 3. Apache mode
  23. 4. Dns mode
  24. #How to use
  25. 1. Clone this project: https://github.com/Neilpang/le.git
  26. 2. Install le:
  27. ```
  28. ./le.sh install
  29. ```
  30. You don't have to be root then, although it is recommended.
  31. Which does 3 jobs:
  32. * create and copy `le.sh` to your home dir: `~/.le`
  33. All the certs will be placed in this folder.
  34. * create alias : `le.sh=~/.le/le.sh` and `le=~/.le/le.sh`.
  35. * create everyday cron job to check and renew the cert if needed.
  36. After install, you must close current terminal and reopen again to make the alias take effect.
  37. Ok, you are ready to issue cert now.
  38. Show help message:
  39. ```
  40. root@v1:~# le.sh
  41. https://github.com/Neilpang/le
  42. v1.1.1
  43. Usage: le.sh [command] ...[args]....
  44. Available commands:
  45. install:
  46. Install le.sh to your system.
  47. issue:
  48. Issue a cert.
  49. installcert:
  50. Install the issued cert to apache/nginx or any other server.
  51. renew:
  52. Renew a cert.
  53. renewAll:
  54. Renew all the certs.
  55. uninstall:
  56. Uninstall le.sh, and uninstall the cron job.
  57. version:
  58. Show version info.
  59. installcronjob:
  60. Install the cron job to renew certs, you don't need to call this. The 'install' command can automatically install the cron job.
  61. uninstallcronjob:
  62. Uninstall the cron job. The 'uninstall' command can do this automatically.
  63. createAccountKey:
  64. Create an account private key, professional use.
  65. createDomainKey:
  66. Create an domain private key, professional use.
  67. createCSR:
  68. Create CSR , professional use.
  69. root@v1:~/le# le issue
  70. Usage: le issue webroot|no|apache|dns a.com [www.a.com,b.com,c.com]|no [key-length]|no
  71. ```
  72. Set the param value to "no" means you want to ignore it.
  73. For example, if you give "no" to "key-length", it will use default length 2048.
  74. And if you give 'no' to 'cert-file-path', it will not copy the issued cert to the "cert-file-path".
  75. In all the cases, the issued cert will be placed in "~/.le/domain.com/"
  76. # Just issue a cert:
  77. Example 1:
  78. Only one domain:
  79. ```
  80. le issue /home/wwwroot/aa.com aa.com
  81. ```
  82. Example 2:
  83. Multiple domains in the same cert:
  84. ```
  85. le issue /home/wwwroot/aa.com aa.com www.aa.com,cp.aa.com
  86. ```
  87. First argument `/home/wwwroot/aa.com` is the web root folder, You must have `write` access to this folder.
  88. Second argument "aa.com" is the main domain you want to issue cert for.
  89. Third argument is the additional domain list you want to use. Comma separated list, which is Optional.
  90. You must point and bind all the domains to the same webroot dir:`/home/wwwroot/aa.com`
  91. The cert will be placed in `~/.le/aa.com/`
  92. The issued cert will be renewed every 80 days automatically.
  93. # Install issued cert to apache/nginx etc.
  94. ```
  95. le installcert aa.com /path/to/certfile/in/apache/nginx /path/to/keyfile/in/apache/nginx /path/to/ca/certfile/apache/nginx "service apache2|nginx reload"
  96. ```
  97. Install the issued cert/key to the production apache or nginx path.
  98. The cert will be renewed every 80 days by default (which is configurable), Once the cert is renewed, the apache/nginx will be automatically reloaded by the command: `service apache2 reload` or `service nginx reload`
  99. # Use Standalone server to issue cert (requires you be root/sudoer, or you have permission to listen tcp 80 port):
  100. Same usage as all above, just give `no` as the webroot.
  101. The tcp `80` port must be free to listen, otherwise you will be prompted to free the `80` port and try again.
  102. ```
  103. le issue no aa.com www.aa.com,cp.aa.com
  104. ```
  105. # Use Apache mode (requires you be root/sudoer, since it is required to interact with apache server):
  106. If you are running a web server, apache or nginx, it is recommended to use the Webroot mode.
  107. Particularly, if you are running an apache server, you can use apache mode instead. Which doesn't write any file to your web root folder.
  108. Just set string "apache" to the first argument, it will use apache plugin automatically.
  109. ```
  110. le issue apache aa.com www.aa.com,user.aa.com
  111. ```
  112. All the other arguments are the same with previous.
  113. # Use DNS mode:
  114. Support the latest dns-01 challenge.
  115. ```
  116. le issue dns aa.com www.aa.com,user.aa.com
  117. ```
  118. You will get the output like bellow:
  119. ```
  120. Add the following txt record:
  121. Domain:_acme-challenge.aa.com
  122. Txt value:9ihDbjYfTExAYeDs4DBUeuTo18KBzwvTEjUnSwd32-c
  123. Add the following txt record:
  124. Domain:_acme-challenge.www.aa.com
  125. Txt value:9ihDbjxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  126. ```
  127. Please add those txt records to the domains. Waiting for the dns to take effect.
  128. Then just retry with 'renew' command:
  129. ```
  130. le renew aa.com
  131. ```
  132. Ok, it's finished.
  133. #Automatic dns api integeration
  134. If your dns provider supports api access, we can use api to automatically issue certs.
  135. You don't have do anything manually.
  136. ###Currently we support:
  137. 1. Cloudflare.com api
  138. 2. Dnspod.cn api
  139. 3. Cloudxns.com api
  140. 4. AWS Route 53, see: https://github.com/Neilpang/le/issues/65
  141. More apis are coming soon....
  142. If your dns provider is not in the supported list above, you can write your own script api easily.
  143. For more details: [How to use dns api](dnsapi)
  144. # Issue ECC certificate:
  145. LetsEncrypt now can issue ECDSA certificate.
  146. And we also support it.
  147. Just set the `length` parameter with a prefix `ec-`.
  148. For example:
  149. Single domain:
  150. ```
  151. le issue /home/wwwroot/aa.com aa.com no ec-256
  152. ```
  153. SAN multiple domains:
  154. ```
  155. le issue /home/wwwroot/aa.com aa.com www.aa.com,cp.aa.com ec-256
  156. ```
  157. Please look at the last parameter above.
  158. Valid values are:
  159. 1. ec-256 (prime256v1, "ECDSA P-256")
  160. 2. ec-384 (secp384r1, "ECDSA P-384")
  161. 3. ec-521 (secp521r1, "ECDSA P-521", which is not supported by letsencrypt yet.)
  162. #Under the Hood
  163. Speak ACME language with bash directly to Let's encrypt.
  164. TODO:
  165. #Acknowledgment
  166. 1. Acme-tiny: https://github.com/diafygi/acme-tiny
  167. 2. ACME protocol: https://github.com/ietf-wg-acme/acme
  168. 3. letsencrypt: https://github.com/letsencrypt/letsencrypt
  169. #License & Other
  170. License is GPLv3
  171. Please Star and Fork me.
  172. Issues and pull requests are welcomed.