You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/202007/enable-two-way-ssl-for-emqx.md
+37-23Lines changed: 37 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
As a security protocol based on modern cryptographic public key algorithms, TLS/SSL can ensure the security of transmission in the computer communication network. EMQX has built-in support for TLS/SSL including one-way/two-ways authentication, the X.509 certificate, load balance SSL and many other security certifications. You can enable SSL/TLS for all protocols supported by EMQX, and can also configure HTTP API provided by EMQX to use TLS.
1
+
As a security protocol based on modern cryptographic public key algorithms, TLS/SSL can ensure the security of transmission in the computer communication network. EMQX has built-in support for TLS/SSL including one-way/two-ways (mutual TLS, or mTLS) authentication, the X.509 certificate, load balance SSL and many other security certifications. You can enable SSL/TLS for all protocols supported by EMQX, and can also configure HTTP API provided by EMQX to use TLS.
2
2
3
3
In the previous article, we've introduced how to [enable SSL/TLS one-way security connection for the EMQX](https://www.emqx.com/en/blog/emqx-server-ssl-tls-secure-connection-configuration-guide). This article will introduce how to enable SSL/TLS two-way security connection for [MQTT](https://www.emqx.com/en/mqtt-guide) in EMQX.
4
4
@@ -22,7 +22,7 @@ The following picture describes the process of the TLS/SSL handshake protocol. F
22
22
23
23
24
24
25
-
## Why do we need SSL/TLS two-way certification
25
+
## Why do we need SSL/TLS two-way (mTLS) certification
26
26
27
27
The two-way certification is that a certificate is required for service and client during the connection authentication. Both parties need to perform authentication for ensuring that both sides involved in communication are trusted. Both parties share their public certificates, and then perform verification and confirmation based on the certificate. For some application scenarios that required high security, we need to enable two-way SSL/TLS authentication.
After preparing the server and client certificate, we can enable TLS/SSL two-way authentication in the EMQX.
123
123
124
124
125
-
126
125
## Enable and verify SSL/TLS two-way connection
127
126
128
-
**In the EMQX, the default listening port of `mqtt:ssl` is 8883.**
127
+
### EMQX v5 configuration
129
128
130
-
### EMQX configuration
129
+
```shell
130
+
listeners.ssl.default {
131
+
bind = "0.0.0.0:8883"
132
+
ssl_options {
133
+
# PEM file containing the trusted CA (certificate authority) certificates that the listener uses to verify the authenticity of the client certificates.
134
+
# For one-way authentication, the file content can be empty.
135
+
cacertfile = "etc/certs/ca.pem"
136
+
# PEM file containing the SSL/TLS certificate chain for the listener.
137
+
# If the certificate is not directly issued by a root CA, the intermediate CA certificates should be appended after the listener certificate to form a chain.
138
+
certfile = "etc/certs/emqx.pem"
139
+
# PEM file containing the private key corresponding to the SSL/TLS certificate.
140
+
keyfile = "etc/certs/emqx.key"
141
+
# Set `verify_peer` to verify the authenticity of the client certificates. Must be set to 'verify_peer' for two-way authentication (mTLS).
142
+
# Set 'verify_none' to allow any client to connect, regardless of the client certificate.
143
+
verify = verify_peer
144
+
# If set to `true`, the handshake fails if the client does not have a certificate to send. Must be set to `true` for two-way authentication (mTLS).
145
+
# If set to `false`, it fails only if the client sends an invalid certificate (an empty certificate is considered valid). i.e. one-way authentication.
146
+
fail_if_no_peer_cert = true
147
+
}
148
+
}
149
+
```
150
+
151
+
### EMQX v4 configuration
152
+
153
+
**In the EMQX, the default listening port of `mqtt:ssl` is 8883.**
131
154
132
155
Copy the file `emqx.pem`, `emqx.key` and `ca.pem` generated by OpenSSL tool into the directory `etc/certs/` of EMQX, and refer the following configuration to modify `emqx.conf`:
133
156
@@ -136,32 +159,23 @@ Copy the file `emqx.pem`, `emqx.key` and `ca.pem` generated by OpenSSL tool into
136
159
## Value: IP:Port | Port
137
160
listener.ssl.external = 8883
138
161
139
-
## Path to the file containing the user's private PEM-encoded key.
140
-
## Value: File
162
+
# PEM file containing the private key corresponding to the SSL/TLS certificate.
## NOTE: If emqx.pem is a certificate chain, please make sure the first certificate is the certificate for the server, but not a CA certificate.
144
-
## Path to a file containing the user certificate.
145
-
## Value: File
165
+
# PEM file containing the SSL/TLS certificate chain for the listener.
166
+
# If the certificate is not directly issued by a root CA, the intermediate CA certificates should be appended after the listener certificate to form a chain.
## Note: ca.pem is to hold the server's intermediate and root CA certificates. Other trusted CAs can be appended for client certificate validation.
149
-
## Path to the file containing PEM-encoded CA certificates. The CA certificates
150
-
## Value: File
169
+
# PEM file containing the trusted CA (certificate authority) certificates that the listener uses to verify the authenticity of the client certificates.
170
+
# For one-way authentication, the file content can be empty.
0 commit comments