Skip to content

Commit 9ba292d

Browse files
committed
Added support for CRL check
1 parent 30b8f91 commit 9ba292d

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Unreleased
2+
- Add support for CRL to check for the server certificate is revocation status.
3+
14
## 3.0.5
25
- Docs: Set the default_codec doc attribute.
36

@@ -37,4 +40,3 @@
3740
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3841
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
3942
- Dependency on logstash-core update to 2.0
40-

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
|=======================================================================
6365

@@ -225,6 +227,24 @@ SSL key passphrase
225227

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

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

lib/logstash/outputs/syslog.rb

Lines changed: 17 additions & 1 deletion
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
@@ -131,7 +137,7 @@ def register
131137
if ssl?
132138
@ssl_context = setup_ssl
133139
end
134-
140+
135141
if @codec.instance_of? LogStash::Codecs::Plain
136142
if @codec.config["format"].nil?
137143
@codec = LogStash::Codecs::Plain.new({"format" => @message})
@@ -223,6 +229,8 @@ def connect
223229
socket
224230
end
225231

232+
CRL_END_TAG = "\n-----END X509 CRL-----\n"
233+
226234
def setup_ssl
227235
require "openssl"
228236
ssl_context = OpenSSL::SSL::SSLContext.new
@@ -237,6 +245,14 @@ def setup_ssl
237245
else
238246
cert_store.add_file(@ssl_cacert)
239247
end
248+
if @ssl_crl
249+
# copy the behavior of X509_load_crl_file() which supports loading bundles of CRLs.
250+
File.read(@ssl_crl).split(CRL_END_TAG).each do |crl|
251+
crl << CRL_END_TAG
252+
cert_store.add_crl(OpenSSL::X509::CRL.new(crl))
253+
end
254+
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
255+
end
240256
ssl_context.cert_store = cert_store
241257
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
242258
end

0 commit comments

Comments
 (0)