Skip to content

Commit 6873a43

Browse files
authored
Merge branch 'v3.0.5-nordix' into structured-data
2 parents 622b522 + cf9eae8 commit 6873a43

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
## Unreleased
1+
## 3.0.5-nordix-3
22
- Added support for RFC5424 structured data.
33

4+
## 3.0.5-nordix-2
5+
- The SNI (Server Name Indication) extension is now used when connecting to syslog server with TLS and `host` is set to FQDN (Fully Qualified Domain Name).
6+
7+
## 3.0.5-nordix-1
8+
- Add support for CRL to check for the server certificate is revocation status.
9+
- Support loading of PKCS8 EC private keys.
10+
411
## 3.0.5
512
- Docs: Set the default_codec doc attribute.
613

docs/index.asciidoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ This plugin supports the following configuration options plus the <<plugins-{typ
5858
| <<plugins-{type}s-{plugin}-ssl_key>> |a valid filesystem path|No
5959
| <<plugins-{type}s-{plugin}-ssl_key_passphrase>> |<<password,password>>|No
6060
| <<plugins-{type}s-{plugin}-ssl_verify>> |<<boolean,boolean>>|No
61+
| <<plugins-{type}s-{plugin}-ssl_crl>> |a valid filesystem path|No
62+
| <<plugins-{type}s-{plugin}-ssl_crl_check_all>> |<<boolean,boolean>>|No
6163
| <<plugins-{type}s-{plugin}-use_labels>> |<<boolean,boolean>>|No
6264
| <<plugins-{type}s-{plugin}-structured_data>> |<<string,string>>|No
6365
|=======================================================================
@@ -226,6 +228,24 @@ SSL key passphrase
226228

227229
Verify the identity of the other end of the SSL connection against the CA.
228230

231+
[id="plugins-{type}s-{plugin}-ssl_crl"]
232+
===== `ssl_crl`
233+
234+
* Value type is <<path,path>>
235+
* There is no default value for this setting.
236+
237+
SSL CRL path for checking the revocation status of the server certificate.
238+
File may contain one or more PEM encoded CRLs.
239+
240+
[id="plugins-{type}s-{plugin}-ssl_crl_check_all"]
241+
===== `ssl_crl_check_all`
242+
243+
* Value type is <<boolean,boolean>>
244+
* Default value is `false`
245+
246+
If this option is set to false, only the certificate at the end of the certificate chain will be subject to validation by CRL.
247+
If set to true the complete chain is validated. CRLs must be available from all CAs.
248+
229249
[id="plugins-{type}s-{plugin}-use_labels"]
230250
===== `use_labels`
231251

lib/logstash/outputs/syslog.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ class LogStash::Outputs::Syslog < LogStash::Outputs::Base
8181
# SSL key passphrase
8282
config :ssl_key_passphrase, :validate => :password, :default => nil
8383

84+
# CRL file or bundle of CRLs
85+
config :ssl_crl, :validate => :path
86+
87+
# Check CRL for only leaf certificate (false) or require CRL check for the complete chain (true)
88+
config :ssl_crl_check_all, :validate => :boolean, :default => false
89+
8490
# use label parsing for severity and facility levels
8591
# use priority field if set to false
8692
config :use_labels, :validate => :boolean, :default => true
@@ -135,7 +141,7 @@ def register
135141
@ssl_context = setup_ssl
136142
end
137143

138-
if @codec.instance_of? LogStash::Codecs::Plain
144+
if @codec.class.to_s == "LogStash::Codecs::Plain"
139145
if @codec.config["format"].nil?
140146
@codec = LogStash::Codecs::Plain.new({"format" => @message})
141147
end
@@ -218,6 +224,8 @@ def connect
218224
socket = TCPSocket.new(@host, @port)
219225
if ssl?
220226
socket = OpenSSL::SSL::SSLSocket.new(socket, @ssl_context)
227+
# Use SNI extension
228+
socket.hostname = @host
221229
begin
222230
socket.connect
223231
rescue OpenSSL::SSL::SSLError => ssle
@@ -232,11 +240,13 @@ def connect
232240
socket
233241
end
234242

243+
CRL_END_TAG = "\n-----END X509 CRL-----\n"
244+
235245
def setup_ssl
236246
require "openssl"
237247
ssl_context = OpenSSL::SSL::SSLContext.new
238248
ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
239-
ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase)
249+
ssl_context.key = OpenSSL::PKey::read(File.read(@ssl_key),@ssl_key_passphrase)
240250
if @ssl_verify
241251
cert_store = OpenSSL::X509::Store.new
242252
# Load the system default certificate path to the store
@@ -246,6 +256,14 @@ def setup_ssl
246256
else
247257
cert_store.add_file(@ssl_cacert)
248258
end
259+
if @ssl_crl
260+
# copy the behavior of X509_load_crl_file() which supports loading bundles of CRLs.
261+
File.read(@ssl_crl).split(CRL_END_TAG).each do |crl|
262+
crl << CRL_END_TAG
263+
cert_store.add_crl(OpenSSL::X509::CRL.new(crl))
264+
end
265+
cert_store.flags = @ssl_crl_check_all ? OpenSSL::X509::V_FLAG_CRL_CHECK|OpenSSL::X509::V_FLAG_CRL_CHECK_ALL : OpenSSL::X509::V_FLAG_CRL_CHECK
266+
end
249267
ssl_context.cert_store = cert_store
250268
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
251269
end

0 commit comments

Comments
 (0)