0017-S2S-TLS-Convert-SSL.txt-to-Markdown-and-update-infor.patch 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. From 3b510a15e0a8d1c8596ce278aeab74edf52cb4e5 Mon Sep 17 00:00:00 2001
  2. From: Alexander Barton <alex@barton.de>
  3. Date: Mon, 8 Jan 2024 18:31:30 +0100
  4. Subject: [PATCH 17/20] S2S-TLS: Convert SSL.txt to Markdown and update
  5. information given
  6. No longer describe creating self-signed certificates or using "stunnel",
  7. as both is not recommended.
  8. (cherry picked from commit b826fad15871f73435328b1d77fd364838389adb)
  9. ---
  10. doc/Makefile.am | 2 +-
  11. doc/SSL.md | 80 +++++++++++++++++++++++++++++++++++
  12. doc/SSL.txt | 108 ------------------------------------------------
  13. 3 files changed, 81 insertions(+), 109 deletions(-)
  14. create mode 100644 doc/SSL.md
  15. delete mode 100644 doc/SSL.txt
  16. --- a/doc/Makefile.am
  17. +++ b/doc/Makefile.am
  18. @@ -33,7 +33,7 @@
  19. README-Interix.txt \
  20. RFC.txt \
  21. Services.txt \
  22. - SSL.txt
  23. + SSL.md
  24. doc_templates = sample-ngircd.conf.tmpl
  25. --- /dev/null
  26. +++ b/doc/SSL.md
  27. @@ -0,0 +1,80 @@
  28. +# [ngIRCd](https://ngircd.barton.de) - SSL/TLS Encrypted Connections
  29. +
  30. +ngIRCd supports SSL/TLS encrypted connections using the *OpenSSL* or *GnuTLS*
  31. +libraries. Both encrypted server-server links as well as client-server links
  32. +are supported.
  33. +
  34. +SSL is a compile-time option which is disabled by default. Use one of these
  35. +options of the ./configure script to enable it:
  36. +
  37. +- `--with-openssl`: enable SSL support using OpenSSL.
  38. +- `--with-gnutls`: enable SSL support using GnuTLS.
  39. +
  40. +You can check the output of `ngircd --version` to validate if your executable
  41. +includes support for SSL or not: "+SSL" must be listed in the feature flags.
  42. +
  43. +You also need a SSL key and certificate, for example using Let's Encrypt, which
  44. +is out of the scope of this document.
  45. +
  46. +From a feature point of view, ngIRCds support for both libraries is
  47. +comparable. The only major difference (at this time) is that ngIRCd with GnuTLS
  48. +does not support password protected private keys.
  49. +
  50. +## Configuration
  51. +
  52. +SSL-encrypted connections and plain-text connects can't run on the same network
  53. +port (which is a limitation of the IRC protocol); therefore you have to define
  54. +separate port(s) in your `[SSL]` block in the configuration file.
  55. +
  56. +A minimal configuration for *accepting* SSL-encrypted client & server
  57. +connections looks like this:
  58. +
  59. +``` ini
  60. +[SSL]
  61. +CertFile = /etc/ssl/certs/my-fullchain.pem
  62. +KeyFile = /etc/ssl/certs/my-privkey.pem
  63. +Ports = 6697, 6698
  64. +```
  65. +
  66. +In this case, the server only deals with *incoming* connections and never has to
  67. +validate SSL certificates itself, and therefore no "Certificate Authorities" are
  68. +needed.
  69. +
  70. +If you want to use *outgoing* SSL-connections to other servers, you need to add:
  71. +
  72. +``` ini
  73. +[SSL]
  74. +...
  75. +CAFile = /etc/ssl/certs/ca-certificates.crt
  76. +DHFile = /etc/ngircd/dhparams.pem
  77. +
  78. +[SERVER]
  79. +...
  80. +SSLConnect = yes
  81. +```
  82. +
  83. +The `CAFile` option configures a file listing all the certificates of the
  84. +trusted Certificate Authorities.
  85. +
  86. +The Diffie-Hellman parameters file `dhparams.pem` can be created like this:
  87. +
  88. +- OpenSSL: `openssl dhparam -2 -out /etc/ngircd/dhparams.pem 4096`
  89. +- GnuTLS: `certtool --generate-dh-params --bits 4096 --outfile /etc/ngircd/dhparams.pem`
  90. +
  91. +Note that enabling `SSLConnect` not only enforces SSL-encrypted links for
  92. +*outgoing* connections to other servers, but for *incoming* connections as well:
  93. +If a server configured with `SSLConnect = yes` tries to connect on a plain-text
  94. +connection, it won't be accepted to prevent data leakage! Therefore you should
  95. +set this for *all* servers you expect to use SSL-encrypted connections!
  96. +
  97. +## Accepting untrusted Remote Certificates
  98. +
  99. +If you are using self-signed certificates or otherwise invalid certificates,
  100. +which ngIRCd would reject by default, you can force ngIRCd to skip certificate
  101. +validation on a per-server basis and continue establishing outgoing connections
  102. +to the respective peer by setting `SSLVerify = no` in the `[SERVER]` block of
  103. +this remote server in your configuration.
  104. +
  105. +But please think twice before doing so: the established connection is still
  106. +encrypted but the remote site is *not verified at all* and man-in-the-middle
  107. +attacks are possible!
  108. --- a/doc/SSL.txt
  109. +++ /dev/null
  110. @@ -1,108 +0,0 @@
  111. -
  112. - ngIRCd - Next Generation IRC Server
  113. -
  114. - (c)2001-2008 Alexander Barton,
  115. - alex@barton.de, http://www.barton.de/
  116. -
  117. - ngIRCd is free software and published under the
  118. - terms of the GNU General Public License.
  119. -
  120. - -- SSL.txt --
  121. -
  122. -
  123. -ngIRCd supports SSL/TLSv1 encrypted connections using the OpenSSL or GnuTLS
  124. -libraries. Both encrypted server-server links as well as client-server links
  125. -are supported.
  126. -
  127. -SSL is a compile-time option which is disabled by default. Use one of these
  128. -options of the ./configure script to enable it:
  129. -
  130. - --with-openssl enable SSL support using OpenSSL
  131. - --with-gnutls enable SSL support using GnuTLS
  132. -
  133. -You also need a key/certificate, see below for how to create a self-signed one.
  134. -
  135. -From a feature point of view, ngIRCds support for both libraries is
  136. -comparable. The only major difference (at this time) is that ngircd with gnutls
  137. -does not support password protected private keys.
  138. -
  139. -Configuration
  140. -~~~~~~~~~~~~~
  141. -
  142. -To enable SSL connections a separate port must be configured: it is NOT
  143. -possible to handle unencrypted and encrypted connections on the same port!
  144. -This is a limitation of the IRC protocol ...
  145. -
  146. -You have to set (at least) the following configuration variables in the
  147. -[SSL] section of ngircd.conf(5): Ports, KeyFile, and CertFile.
  148. -
  149. -Now IRC clients are able to connect using SSL on the configured port(s).
  150. -(Using port 6697 for encrypted connections is common.)
  151. -
  152. -To enable encrypted server-server links, you have to additionally set
  153. -SSLConnect to "yes" in the corresponding [SERVER] section.
  154. -
  155. -
  156. -Creating a self-signed certificate
  157. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  158. -
  159. -OpenSSL:
  160. -
  161. -Creating a self-signed certificate and key:
  162. - $ openssl req -newkey rsa:2048 -x509 -keyout server-key.pem -out server-cert.pem -days 1461
  163. -Create DH parameters (optional):
  164. - $ openssl dhparam -2 -out dhparams.pem 4096
  165. -
  166. -GnuTLS:
  167. -
  168. -Creating a self-signed certificate and key:
  169. - $ certtool --generate-privkey --bits 2048 --outfile server-key.pem
  170. - $ certtool --generate-self-signed --load-privkey server-key.pem --outfile server-cert.pem
  171. -Create DH parameters (optional):
  172. - $ certtool --generate-dh-params --bits 4096 --outfile dhparams.pem
  173. -
  174. -
  175. -Alternate approach using stunnel(1)
  176. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  177. -
  178. -Alternatively (or if you are using ngIRCd compiled without support
  179. -for GnuTLS/OpenSSL), you can use external programs/tools like stunnel(1) to
  180. -get SSL encrypted connections:
  181. -
  182. - <http://stunnel.mirt.net/>
  183. - <http://www.stunnel.org/>
  184. -
  185. -Stefan Sperling (stefan at binarchy dot net) mailed the following text as a
  186. -short "how-to", thanks Stefan!
  187. -
  188. -=== snip ===
  189. - ! This guide applies to stunnel 4.x !
  190. -
  191. - Put this in your stunnel.conf:
  192. -
  193. - [ircs]
  194. - accept = 6667
  195. - connect = 6668
  196. -
  197. - This makes stunnel listen for incoming connections
  198. - on port 6667 and forward decrypted data to port 6668.
  199. - We call the connection 'ircs'. Stunnel will use this
  200. - name when logging connection attempts via syslog.
  201. - You can also use the name in /etc/hosts.{allow,deny}
  202. - if you run tcp-wrappers.
  203. -
  204. - To make sure ngircd is listening on the port where
  205. - the decrypted data arrives, set
  206. -
  207. - Ports = 6668
  208. -
  209. - in your ngircd.conf.
  210. -
  211. - Start stunnel and restart ngircd.
  212. -
  213. - That's it.
  214. - Don't forget to activate ssl support in your irc client ;)
  215. - The main drawback of this approach compared to using builtin ssl
  216. - is that from ngIRCds point of view, all ssl-enabled client connections will
  217. - originate from the host running stunnel.
  218. -=== snip ===
  219. --- a/doc/Makefile.in
  220. +++ b/doc/Makefile.in
  221. @@ -243,7 +243,7 @@
  222. README-Interix.txt \
  223. RFC.txt \
  224. Services.txt \
  225. - SSL.txt
  226. + SSL.md
  227. doc_templates = sample-ngircd.conf.tmpl
  228. generated_docs = sample-ngircd.conf