@@ -43,7 +43,7 @@ public function __invoke(array $config): Logger
43
43
$ config ['host ' ] ?? '127.0.0.1 ' ,
44
44
$ config ['port ' ] ?? 12201 ,
45
45
$ config ['path ' ] ?? null ,
46
- $ config[ ' ssl ' ] ?? null
46
+ $ this -> enableSsl ( $ config) ? $ this -> sslOptions ( $ config [ ' ssl_options ' ] ?? null ) : null
47
47
)
48
48
);
49
49
@@ -70,18 +70,43 @@ protected function getTransport(
70
70
string $ host ,
71
71
int $ port ,
72
72
?string $ path = null ,
73
- ? array $ ssl = null
73
+ ? SslOptions $ sslOptions = null
74
74
): AbstractTransport {
75
75
switch (strtolower ($ transport )) {
76
76
case 'tcp ' :
77
- return new TcpTransport ($ host , $ port , $ this -> createSsl ( $ ssl ) );
78
- case 'http ' :
79
- return new HttpTransport ($ host , $ port , $ path ?? HttpTransport::DEFAULT_PATH );
77
+ return new TcpTransport ($ host , $ port , $ sslOptions );
78
+ case 'http ' :
79
+ return new HttpTransport ($ host , $ port , $ path ?? HttpTransport::DEFAULT_PATH , $ sslOptions );
80
80
default :
81
81
return new UdpTransport ($ host , $ port );
82
82
}
83
83
}
84
84
85
+ protected function enableSsl (array $ config ): bool
86
+ {
87
+ if (! isset ($ config ['transport ' ]) || $ config ['transport ' ] === 'udp ' ) {
88
+ return false ;
89
+ }
90
+
91
+ return $ config ['ssl ' ] ?? false ;
92
+ }
93
+
94
+ protected function sslOptions (?array $ sslConfig = null ): SslOptions
95
+ {
96
+ $ sslOptions = new SslOptions ();
97
+
98
+ if (! $ sslConfig ) {
99
+ return $ sslOptions ;
100
+ }
101
+
102
+ $ sslOptions ->setVerifyPeer ($ sslConfig ['verify_peer ' ] ?? true );
103
+ $ sslOptions ->setCaFile ($ sslConfig ['ca_file ' ] ?? null );
104
+ $ sslOptions ->setCiphers ($ sslConfig ['ciphers ' ] ?? null );
105
+ $ sslOptions ->setAllowSelfSigned ($ sslConfig ['allow_self_signed ' ] ?? false );
106
+
107
+ return $ sslOptions ;
108
+ }
109
+
85
110
/** @throws \InvalidArgumentException */
86
111
protected function level (array $ config ): int
87
112
{
@@ -120,19 +145,4 @@ protected function getFallbackChannelName(): string
120
145
{
121
146
return $ this ->app ->bound ('env ' ) ? $ this ->app ->environment () : 'production ' ;
122
147
}
123
-
124
- private function createSsl (?array $ ssl ): ?SslOptions
125
- {
126
- if (empty ($ ssl )) {
127
- return null ;
128
- }
129
-
130
- $ sslOptions = new SslOptions ();
131
- $ sslOptions ->setAllowSelfSigned ($ ssl ['allow_self_signed ' ] ?? false );
132
- $ sslOptions ->setCaFile ($ ssl ['ca_file ' ] ?? null );
133
- $ sslOptions ->setCiphers ($ ssl ['ciphers ' ] ?? null );
134
- $ sslOptions ->setVerifyPeer ($ ssl ['verify_peer ' ] ?? true );
135
-
136
- return $ sslOptions ;
137
- }
138
148
}
0 commit comments