Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Mqtt Cluster
Commits
9599e797
Commit
9599e797
authored
3 years ago
by
luxurong
Browse files
Options
Download
Email Patches
Plain Diff
ssl
parent
cee90a28
main
1.1.2
1.1.3
1.1.4
1.1.5
feature/mqtt-5.0-support
merge_
release/bug-fix
1.1.4
1.1.3
1.1.2
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smqtt-common/src/main/java/io/github/quickmsg/common/config/SslContext.java
+2
-0
...ain/java/io/github/quickmsg/common/config/SslContext.java
smqtt-core/src/main/java/io/github/quickmsg/core/ssl/AbstractSslHandler.java
+6
-5
.../java/io/github/quickmsg/core/ssl/AbstractSslHandler.java
with
8 additions
and
5 deletions
+8
-5
smqtt-common/src/main/java/io/github/quickmsg/common/config/SslContext.java
+
2
-
0
View file @
9599e797
package
io.github.quickmsg.common.config
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
@@ -8,6 +9,7 @@ import lombok.NoArgsConstructor;
*/
@Data
@NoArgsConstructor
@Builder
public
class
SslContext
{
private
String
crt
;
...
...
This diff is collapsed.
Click to expand it.
smqtt-core/src/main/java/io/github/quickmsg/core/ssl/AbstractSslHandler.java
+
6
-
5
View file @
9599e797
...
...
@@ -4,11 +4,11 @@ import io.github.quickmsg.common.config.Configuration;
import
io.github.quickmsg.common.config.SslContext
;
import
io.github.quickmsg.core.mqtt.MqttConfiguration
;
import
io.netty.channel.ChannelOption
;
import
io.netty.handler.ssl.SslContextBuilder
;
import
io.netty.handler.ssl.util.SelfSignedCertificate
;
import
lombok.extern.slf4j.Slf4j
;
import
reactor.netty.tcp.SslProvider
;
import
reactor.netty.tcp.TcpServer
;
import
reactor.netty.tcp.TcpSslContextSpec
;
import
java.io.File
;
import
java.util.Map
;
...
...
@@ -25,7 +25,7 @@ public class AbstractSslHandler {
File
cert
;
File
key
;
SslContext
sslContext
=
configuration
.
getSslContext
();
if
(
sslContext
!=
null
)
{
if
(
sslContext
!=
null
&&
sslContext
.
getCrt
()
!=
null
&&
sslContext
.
getKey
()
!=
null
)
{
cert
=
new
File
(
sslContext
.
getCrt
());
key
=
new
File
(
sslContext
.
getKey
());
...
...
@@ -33,9 +33,10 @@ public class AbstractSslHandler {
SelfSignedCertificate
ssc
=
new
SelfSignedCertificate
();
cert
=
ssc
.
certificate
();
key
=
ssc
.
privateKey
();
log
.
error
(
"SelfSignedCertificate cert {} key {}"
,
cert
.
getAbsolutePath
(),
key
.
getAbsolutePath
());
}
SslContext
Builder
sslContextBuilder
=
SslContext
Builder
.
forServer
(
cert
,
key
);
sslContextSpec
.
sslContext
(
s
slContext
Builder
);
Tcp
SslContext
Spec
tcpSslContextSpec
=
Tcp
SslContext
Spec
.
forServer
(
cert
,
key
);
sslContextSpec
.
sslContext
(
tcpS
slContext
Spec
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -48,7 +49,7 @@ public class AbstractSslHandler {
public
TcpServer
initTcpServer
(
MqttConfiguration
mqttConfiguration
)
{
TcpServer
server
=
TcpServer
.
create
();
if
(
mqttConfiguration
.
getSsl
())
{
server
.
secure
(
sslContextSpec
->
this
.
secure
(
sslContextSpec
,
mqttConfiguration
));
server
=
server
.
secure
(
sslContextSpec
->
this
.
secure
(
sslContextSpec
,
mqttConfiguration
));
}
if
(
mqttConfiguration
.
getOptions
()
!=
null
)
{
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
mqttConfiguration
.
getOptions
().
entrySet
())
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help