logstash-input-tcp 5.2.0-java → 5.2.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/docs/index.asciidoc +2 -2
- data/lib/logstash/inputs/tcp/compat_ssl_options.rb +55 -13
- data/lib/logstash/inputs/tcp.rb +1 -5
- data/logstash-input-tcp.gemspec +5 -1
- data/spec/inputs/tcp_spec.rb +114 -47
- data/spec/spec_helper.rb +33 -4
- data/vendor/jar-dependencies/org/logstash/inputs/{logstash-input-tcp/5.2.0/logstash-input-tcp-5.2.0.jar → plugin/5.2.4/plugin-5.2.4.jar} +0 -0
- data/version +1 -1
- metadata +22 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b52419a2f779553c52739d999b5596deb3bc2b7e71fe5ad57b002f2c1da36924
|
4
|
+
data.tar.gz: d9fbaecd56643cc14d1696407f24db9e764f9b011701d497c7a2ada25591faee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4428f7df91b52d98c14c499dc70b971afb40629d9b342dea8026327ce5363fc7542ff9100af7e2144be998773e8fe9b9a793e3f7bed19635dd6d11a7e682c58e
|
7
|
+
data.tar.gz: 4693d64f8f6adf2c4a4e95004f532f0457e8e78914fdefd04e435c06b3914793ef65f34202364a4f5a2318a4ada7e3d518fc9b29b29700d99307ab2da5d795ab
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 5.2.4
|
2
|
+
- Update Log4j dependency to 2.16, ensuring this plugin's runtime relies only on log4j-api instead
|
3
|
+
of providing its own log4j-core [#189](https://github.com/logstash-plugins/logstash-input-tcp/pull/189)
|
4
|
+
|
5
|
+
## 5.2.3
|
6
|
+
- Skip empty lines while reading certificate files [#144](https://github.com/logstash-plugins/logstash-input-tcp/issues/144)
|
7
|
+
|
8
|
+
## 5.2.2
|
9
|
+
- Fixed race condition where data would be accepted before queue was configured [#142](https://github.com/logstash-plugins/logstash-input-tcp/pull/142)
|
10
|
+
|
11
|
+
## 5.2.1
|
12
|
+
- Support multiple certificates per file [#140](https://github.com/logstash-plugins/logstash-input-tcp/pull/140)
|
13
|
+
- Fixed support for encrypted pkcs8 private keys [#133](https://github.com/logstash-plugins/logstash-input-tcp/pull/133)
|
14
|
+
- Added support for encrypted pem pkcs1 private keys [#131](https://github.com/logstash-plugins/logstash-input-tcp/pull/131)
|
15
|
+
- Changed testing to docker [#128](https://github.com/logstash-plugins/logstash-input-tcp/pull/128)
|
16
|
+
- Fixed heading for `ssl_certificate_authorities` docs [#130](https://github.com/logstash-plugins/logstash-input-tcp/pull/130)
|
17
|
+
|
1
18
|
## 5.2.0
|
2
19
|
- Added support for pkcs1 and pkcs8 key formats [#122](https://github.com/logstash-plugins/logstash-input-tcp/issues/122)
|
3
20
|
- Changed server-mode SSL to run on top of Netty [#122](https://github.com/logstash-plugins/logstash-input-tcp/issues/122)
|
data/docs/index.asciidoc
CHANGED
@@ -145,7 +145,7 @@ Path to certificate in PEM format. This certificate will be presented
|
|
145
145
|
to the connecting clients.
|
146
146
|
|
147
147
|
[id="plugins-{type}s-{plugin}-ssl_certificate_authorities"]
|
148
|
-
===== `
|
148
|
+
===== `ssl_certificate_authorities`
|
149
149
|
|
150
150
|
* Value type is <<array,array>>
|
151
151
|
* Default value is `[]`
|
@@ -218,4 +218,4 @@ at the TCP layer and IPs will not be resolved to hostnames.
|
|
218
218
|
[id="plugins-{type}s-{plugin}-common-options"]
|
219
219
|
include::{include_path}/{type}.asciidoc[]
|
220
220
|
|
221
|
-
:default_codec!:
|
221
|
+
:default_codec!:
|
@@ -7,9 +7,15 @@ java_import 'java.io.FileReader'
|
|
7
7
|
java_import 'java.security.cert.CertificateFactory'
|
8
8
|
java_import 'java.security.cert.X509Certificate'
|
9
9
|
java_import 'org.bouncycastle.asn1.pkcs.PrivateKeyInfo'
|
10
|
+
java_import 'org.bouncycastle.jce.provider.BouncyCastleProvider'
|
10
11
|
java_import 'org.bouncycastle.openssl.PEMKeyPair'
|
11
12
|
java_import 'org.bouncycastle.openssl.PEMParser'
|
13
|
+
java_import 'org.bouncycastle.openssl.PEMEncryptedKeyPair'
|
12
14
|
java_import 'org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter'
|
15
|
+
java_import 'org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder'
|
16
|
+
java_import 'org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8DecryptorProviderBuilder'
|
17
|
+
java_import 'org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfo'
|
18
|
+
|
13
19
|
|
14
20
|
# Simulate a normal SslOptions builder:
|
15
21
|
#
|
@@ -70,34 +76,70 @@ class SslOptions
|
|
70
76
|
# create certificate object
|
71
77
|
cf = CertificateFactory.getInstance("X.509")
|
72
78
|
cert_chain = []
|
73
|
-
|
79
|
+
fetch_certificates_from_file(@ssl_cert_path, cf) do |cert|
|
80
|
+
cert_chain << cert
|
81
|
+
end
|
74
82
|
|
75
83
|
# convert key from pkcs1 to pkcs8 and get PrivateKey object
|
76
84
|
pem_parser = PEMParser.new(FileReader.new(@ssl_key_path))
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
java.security.Security.addProvider(BouncyCastleProvider.new)
|
86
|
+
converter = JcaPEMKeyConverter.new
|
87
|
+
case obj = pem_parser.readObject
|
88
|
+
when PEMKeyPair # unencrypted pkcs#1
|
89
|
+
private_key = converter.getKeyPair(obj).private
|
90
|
+
when PrivateKeyInfo # unencrypted pkcs#8
|
91
|
+
private_key = converter.getPrivateKey(obj)
|
92
|
+
when PEMEncryptedKeyPair # encrypted pkcs#1
|
93
|
+
key_char_array = @ssl_key_passphrase.to_java.toCharArray
|
94
|
+
decryptor = JcePEMDecryptorProviderBuilder.new.build(key_char_array)
|
95
|
+
key_pair = obj.decryptKeyPair(decryptor)
|
96
|
+
private_key = converter.getKeyPair(key_pair).private
|
97
|
+
when PKCS8EncryptedPrivateKeyInfo # encrypted pkcs#8
|
98
|
+
key_char_array = @ssl_key_passphrase.to_java.toCharArray
|
99
|
+
key = JceOpenSSLPKCS8DecryptorProviderBuilder.new.build(key_char_array)
|
100
|
+
private_key = converter.getPrivateKey(obj.decryptPrivateKeyInfo(key))
|
83
101
|
else
|
84
102
|
raise "Could not recognize 'ssl_key' format. Class: #{obj.class}"
|
85
103
|
end
|
86
104
|
|
87
|
-
@ssl_extra_chain_certs.each do |
|
88
|
-
|
105
|
+
@ssl_extra_chain_certs.each do |file|
|
106
|
+
fetch_certificates_from_file(file, cf) do |cert|
|
107
|
+
cert_chain << cert
|
108
|
+
end
|
89
109
|
end
|
90
|
-
sslContextBuilder = SslContextBuilder.forServer(private_key, @ssl_key_passphrase, cert_chain.to_java(
|
110
|
+
sslContextBuilder = SslContextBuilder.forServer(private_key, @ssl_key_passphrase, cert_chain.to_java(X509Certificate))
|
91
111
|
|
92
|
-
trust_certs =
|
93
|
-
|
112
|
+
trust_certs = []
|
113
|
+
|
114
|
+
@ssl_certificate_authorities.each do |file|
|
115
|
+
fetch_certificates_from_file(file, cf) do |cert|
|
116
|
+
trust_certs << cert
|
117
|
+
end
|
94
118
|
end
|
95
119
|
|
96
120
|
if trust_certs.any?
|
97
|
-
sslContextBuilder.trustManager(trust_certs.to_java(
|
121
|
+
sslContextBuilder.trustManager(trust_certs.to_java(X509Certificate))
|
98
122
|
end
|
99
123
|
|
100
124
|
sslContextBuilder.clientAuth(@ssl_verify ? ClientAuth::REQUIRE : ClientAuth::NONE)
|
101
125
|
sslContextBuilder.build()
|
102
126
|
end
|
127
|
+
|
128
|
+
private
|
129
|
+
def fetch_certificates_from_file(file, cf)
|
130
|
+
fis = java.io.FileInputStream.new(file)
|
131
|
+
|
132
|
+
while (fis.available > 0) do
|
133
|
+
cert = generate_certificate(cf, fis)
|
134
|
+
yield cert if cert
|
135
|
+
end
|
136
|
+
ensure
|
137
|
+
fis.close if fis
|
138
|
+
end
|
139
|
+
|
140
|
+
def generate_certificate(cf, fis)
|
141
|
+
cf.generateCertificate(fis)
|
142
|
+
rescue Java::JavaSecurityCert::CertificateException => e
|
143
|
+
raise e unless e.cause.message == "Empty input"
|
144
|
+
end
|
103
145
|
end
|
data/lib/logstash/inputs/tcp.rb
CHANGED
@@ -141,11 +141,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
141
141
|
def register
|
142
142
|
fix_streaming_codecs
|
143
143
|
|
144
|
-
# note that since we are opening a socket in register, we must also make sure we close it
|
145
|
-
# in the close method even if we also close it in the stop method since we could have
|
146
|
-
# a situation where register is called but not run & stop.
|
147
|
-
|
148
|
-
@logger.info("Starting tcp input listener", :address => "#{@host}:#{@port}", :ssl_enable => "#{@ssl_enable}")
|
149
144
|
if server?
|
150
145
|
ssl_context = get_ssl_context(SslOptions)
|
151
146
|
|
@@ -157,6 +152,7 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
157
152
|
def run(output_queue)
|
158
153
|
@output_queue = output_queue
|
159
154
|
if server?
|
155
|
+
@logger.info("Starting tcp input listener", :address => "#{@host}:#{@port}", :ssl_enable => "#{@ssl_enable}")
|
160
156
|
@loop.run
|
161
157
|
else
|
162
158
|
run_client()
|
data/logstash-input-tcp.gemspec
CHANGED
@@ -31,7 +31,11 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_runtime_dependency 'logstash-codec-json_lines'
|
32
32
|
s.add_runtime_dependency 'logstash-codec-multiline'
|
33
33
|
|
34
|
-
|
34
|
+
# 5.x branch of this plugin provides support for LS5&6.
|
35
|
+
# To use LS7+, you must use v6+ of this plugin.
|
36
|
+
s.add_runtime_dependency 'logstash-core', '< 7.0.0'
|
37
|
+
|
38
|
+
s.add_development_dependency 'logstash-devutils', '~> 1.0'
|
35
39
|
s.add_development_dependency 'flores', '~> 0.0.6'
|
36
40
|
s.add_development_dependency 'stud', '~> 0.0.22'
|
37
41
|
end
|
data/spec/inputs/tcp_spec.rb
CHANGED
@@ -382,6 +382,35 @@ describe LogStash::Inputs::Tcp do
|
|
382
382
|
ssc.delete
|
383
383
|
end
|
384
384
|
end
|
385
|
+
|
386
|
+
context "with multiple certificates with empty spaces in them" do
|
387
|
+
let(:ssc) { SelfSignedCertificate.new }
|
388
|
+
let(:certificate_file) { ssc.certificate }
|
389
|
+
let(:key_file) { ssc.private_key}
|
390
|
+
let(:ssc_2) { SelfSignedCertificate.new }
|
391
|
+
let(:certificate_file_2) { ssc.certificate }
|
392
|
+
let(:config) do
|
393
|
+
{
|
394
|
+
"host" => "127.0.0.1",
|
395
|
+
"port" => port,
|
396
|
+
"ssl_enable" => true,
|
397
|
+
"ssl_cert" => certificate_file.path,
|
398
|
+
"ssl_key" => key_file.path
|
399
|
+
}
|
400
|
+
end
|
401
|
+
before(:each) do
|
402
|
+
File.open(certificate_file.path, "a") do |file|
|
403
|
+
path = ssc_2.certificate.path
|
404
|
+
file.puts("\n")
|
405
|
+
file.puts(IO.read(path))
|
406
|
+
file.puts("\n")
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
it "should register without errors" do
|
411
|
+
expect { subject.register }.to_not raise_error
|
412
|
+
end
|
413
|
+
end
|
385
414
|
end
|
386
415
|
end
|
387
416
|
|
@@ -391,41 +420,16 @@ describe LogStash::Inputs::Tcp do
|
|
391
420
|
end
|
392
421
|
|
393
422
|
context "when ssl_enable is true" do
|
394
|
-
let(:ssc) { SelfSignedCertificate.new }
|
395
|
-
let(:certificate_file) { ssc.certificate }
|
396
|
-
let(:key_file) { ssc.private_key}
|
397
|
-
let(:queue) { Queue.new }
|
398
|
-
|
399
|
-
let(:config) do
|
400
|
-
{
|
401
|
-
"host" => "127.0.0.1",
|
402
|
-
"port" => port,
|
403
|
-
"ssl_enable" => true,
|
404
|
-
"ssl_cert" => certificate_file.path,
|
405
|
-
"ssl_key" => key_file.path,
|
406
|
-
"ssl_certificate_authorities" => [ certificate_file.path ]
|
407
|
-
}
|
408
|
-
end
|
409
|
-
|
410
423
|
let(:input) { subject }
|
411
|
-
|
412
|
-
|
424
|
+
let(:queue) { Queue.new }
|
425
|
+
before(:each) { subject.register }
|
413
426
|
|
414
427
|
context "when using a certificate chain" do
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
"port" => port,
|
420
|
-
"ssl_enable" => true,
|
421
|
-
"ssl_cert" => chain_of_certificates[:b_cert].path,
|
422
|
-
"ssl_key" => chain_of_certificates[:b_key].path,
|
423
|
-
"ssl_extra_chain_certs" => [ chain_of_certificates[:a_cert].path ],
|
424
|
-
"ssl_certificate_authorities" => [ chain_of_certificates[:root_ca].path ],
|
425
|
-
"ssl_verify" => true
|
426
|
-
}
|
428
|
+
chain_of_certificates = TcpHelpers.new.chain_of_certificates
|
429
|
+
|
430
|
+
let(:tcp) do
|
431
|
+
Stud::try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
427
432
|
end
|
428
|
-
let(:tcp) { TCPSocket.new("127.0.0.1", port) }
|
429
433
|
let(:sslcontext) do
|
430
434
|
sslcontext = OpenSSL::SSL::SSLContext.new
|
431
435
|
sslcontext.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
@@ -435,23 +439,86 @@ describe LogStash::Inputs::Tcp do
|
|
435
439
|
sslcontext
|
436
440
|
end
|
437
441
|
let(:sslsocket) { OpenSSL::SSL::SSLSocket.new(tcp, sslcontext) }
|
438
|
-
let(:
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
+
let(:message) { "message to #{port}" }
|
443
|
+
|
444
|
+
context "with a non encrypted private key" do
|
445
|
+
let(:config) do
|
446
|
+
{
|
447
|
+
"host" => "127.0.0.1",
|
448
|
+
"port" => port,
|
449
|
+
"ssl_enable" => true,
|
450
|
+
"ssl_cert" => chain_of_certificates[:b_cert].path,
|
451
|
+
"ssl_key" => chain_of_certificates[:b_key].path,
|
452
|
+
"ssl_extra_chain_certs" => [ chain_of_certificates[:a_cert].path ],
|
453
|
+
"ssl_certificate_authorities" => [ chain_of_certificates[:root_ca].path ],
|
454
|
+
"ssl_verify" => true
|
455
|
+
}
|
456
|
+
end
|
457
|
+
it "should be able to connect and write data" do
|
458
|
+
result = TcpHelpers.pipelineless_input(subject, 1) do
|
459
|
+
sslsocket.connect
|
460
|
+
sslsocket.write("#{message}\n")
|
461
|
+
tcp.flush
|
462
|
+
sslsocket.close
|
463
|
+
tcp.close
|
464
|
+
end
|
465
|
+
expect(result.size).to eq(1)
|
466
|
+
expect(result.first.get("message")).to eq(message)
|
467
|
+
end
|
442
468
|
end
|
443
469
|
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
470
|
+
context "when using an encrypted private pkcs1 key" do
|
471
|
+
let(:config) do
|
472
|
+
{
|
473
|
+
"host" => "127.0.0.1",
|
474
|
+
"port" => port,
|
475
|
+
"ssl_enable" => true,
|
476
|
+
"ssl_cert" => chain_of_certificates[:be_cert].path,
|
477
|
+
"ssl_key" => chain_of_certificates[:be_key].path,
|
478
|
+
"ssl_key_passphrase" => "passpasspassword",
|
479
|
+
"ssl_extra_chain_certs" => [ chain_of_certificates[:a_cert].path ],
|
480
|
+
"ssl_certificate_authorities" => [ chain_of_certificates[:root_ca].path ],
|
481
|
+
"ssl_verify" => true
|
482
|
+
}
|
483
|
+
end
|
484
|
+
it "should be able to connect and write data" do
|
485
|
+
result = TcpHelpers.pipelineless_input(subject, 1) do
|
486
|
+
sslsocket.connect
|
487
|
+
sslsocket.write("#{message}\n")
|
488
|
+
tcp.flush
|
489
|
+
sslsocket.close
|
490
|
+
tcp.close
|
491
|
+
end
|
492
|
+
expect(result.size).to eq(1)
|
493
|
+
expect(result.first.get("message")).to eq(message)
|
494
|
+
end
|
495
|
+
end
|
496
|
+
context "when using an encrypted private pkcs8 key" do
|
497
|
+
let(:config) do
|
498
|
+
{
|
499
|
+
"host" => "127.0.0.1",
|
500
|
+
"port" => port,
|
501
|
+
"ssl_enable" => true,
|
502
|
+
"ssl_cert" => chain_of_certificates[:be_cert].path,
|
503
|
+
"ssl_key" => chain_of_certificates[:be_key_pkcs8].path,
|
504
|
+
"ssl_key_passphrase" => "passpasspassword",
|
505
|
+
"ssl_extra_chain_certs" => [ chain_of_certificates[:a_cert].path ],
|
506
|
+
"ssl_certificate_authorities" => [ chain_of_certificates[:root_ca].path ],
|
507
|
+
"ssl_verify" => true
|
508
|
+
}
|
509
|
+
end
|
510
|
+
it "should be able to connect and write data" do
|
511
|
+
result = TcpHelpers.pipelineless_input(subject, 1) do
|
512
|
+
sslsocket.connect
|
513
|
+
sslsocket.write("#{message}\n")
|
514
|
+
tcp.flush
|
515
|
+
sslsocket.close
|
516
|
+
tcp.close
|
517
|
+
end
|
518
|
+
expect(result.size).to eq(1)
|
519
|
+
expect(result.first.get("message")).to eq(message)
|
520
|
+
end
|
453
521
|
end
|
454
|
-
|
455
522
|
end
|
456
523
|
|
457
524
|
context "with a poorly-behaving client" do
|
@@ -459,7 +526,7 @@ describe LogStash::Inputs::Tcp do
|
|
459
526
|
|
460
527
|
context "that disconnects before doing TLS handshake" do
|
461
528
|
before do
|
462
|
-
client = TCPSocket.new("127.0.0.1", port)
|
529
|
+
client = Stud::try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
463
530
|
client.close
|
464
531
|
end
|
465
532
|
|
@@ -491,7 +558,7 @@ describe LogStash::Inputs::Tcp do
|
|
491
558
|
# Assertion to verify this test is actually sending something.
|
492
559
|
expect(garbage.length).to be > 0
|
493
560
|
|
494
|
-
client = TCPSocket.new("127.0.0.1", port)
|
561
|
+
client = Stud::try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
495
562
|
client.write(garbage)
|
496
563
|
client.flush
|
497
564
|
Thread.new { sleep(1); client.close }
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,15 @@ require "logstash/devutils/rspec/spec_helper"
|
|
3
3
|
require "tempfile"
|
4
4
|
require "stud/temporary"
|
5
5
|
|
6
|
+
java_import 'org.bouncycastle.openssl.jcajce.JceOpenSSLPKCS8EncryptorBuilder'
|
7
|
+
java_import 'org.bouncycastle.openssl.jcajce.JcaPEMWriter'
|
8
|
+
java_import 'org.bouncycastle.openssl.jcajce.JcaPKCS8Generator'
|
9
|
+
java_import 'org.bouncycastle.jce.provider.BouncyCastleProvider'
|
6
10
|
# this has been taken from the udp input, it should be DRYed
|
7
11
|
|
8
12
|
class TcpHelpers
|
9
13
|
|
10
|
-
def pipelineless_input(plugin, size, &block)
|
14
|
+
def self.pipelineless_input(plugin, size, &block)
|
11
15
|
queue = Queue.new
|
12
16
|
input_thread = Thread.new do
|
13
17
|
plugin.run(queue)
|
@@ -32,12 +36,32 @@ class TcpHelpers
|
|
32
36
|
a_cert, a_key = build_certificate(root_ca, root_key, "A_Cert")
|
33
37
|
aa_cert, aa_key = build_certificate(root_ca, root_key, "AA_Cert")
|
34
38
|
b_cert, b_key = build_certificate(a_cert, a_key, "B_Cert")
|
39
|
+
be_cert, be_key, be_key_text = build_certificate(a_cert, a_key, "BE_Cert", "passpasspassword")
|
40
|
+
be_key_pkcs8 = convert_private_key_to_pkcs8_with_passpharse(be_key, "passpasspassword")
|
35
41
|
c_cert, c_key = build_certificate(b_cert, b_key, "C_Cert")
|
36
42
|
{ :root_ca => new_temp_file('', root_ca), :root_key => new_temp_file('', root_key),
|
37
43
|
:a_cert => new_temp_file('', a_cert), :a_key => new_temp_file('', a_key),
|
38
44
|
:aa_cert => new_temp_file('', aa_cert), :aa_key => new_temp_file('', aa_key),
|
39
45
|
:b_cert => new_temp_file('', b_cert), :b_key => new_temp_file('', b_key),
|
40
|
-
:
|
46
|
+
:be_cert => new_temp_file('', be_cert), :be_key => new_temp_file('', be_key_text), :be_key_pkcs8 => new_temp_file('', be_key_pkcs8),
|
47
|
+
:c_cert => new_temp_file('', c_cert), :c_key => new_temp_file('', c_key),
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def convert_private_key_to_pkcs8_with_passpharse(pkcs1key, passphrase)
|
52
|
+
pem_parser = PEMParser.new(java.io.StringReader.new(pkcs1key.to_pem))
|
53
|
+
kp = pem_parser.read_object
|
54
|
+
java.security.Security.addProvider(BouncyCastleProvider.new)
|
55
|
+
converter = JcaPEMKeyConverter.new.setProvider("BC")
|
56
|
+
key = converter.getPrivateKey(kp.get_private_key_info)
|
57
|
+
alg = org.bouncycastle.openssl.PKCS8Generator::PBE_SHA1_RC4_128
|
58
|
+
enc = JceOpenSSLPKCS8EncryptorBuilder.new(alg).set_passsword(passphrase.to_java.to_char_array).build
|
59
|
+
sw = java.io.StringWriter.new
|
60
|
+
writer = JcaPEMWriter.new(sw)
|
61
|
+
writer.write_object(JcaPKCS8Generator.new(key, enc))
|
62
|
+
writer.flush
|
63
|
+
writer.close
|
64
|
+
sw
|
41
65
|
end
|
42
66
|
|
43
67
|
private
|
@@ -49,12 +73,17 @@ class TcpHelpers
|
|
49
73
|
file
|
50
74
|
end
|
51
75
|
|
52
|
-
def build_certificate(root_ca, root_key
|
76
|
+
def build_certificate(root_ca, root_key, name, password=nil)
|
53
77
|
key = ( root_key.nil? ? OpenSSL::PKey::RSA.new(2048) : root_key )
|
54
78
|
options = { :serial => 2, :subject => "/DC=org/DC=ruby-lang/CN=Ruby#{name}", :key => key, :issuer => root_ca.subject}
|
55
79
|
cert = new_certificate(options)
|
56
80
|
add_ca_extensions(cert, nil, root_ca)
|
57
|
-
|
81
|
+
if password
|
82
|
+
key_text = key.to_pem(OpenSSL::Cipher::AES256.new(:CFB), password)
|
83
|
+
[ cert.sign(key, OpenSSL::Digest::SHA256.new), key, key_text ]
|
84
|
+
else
|
85
|
+
[ cert.sign(key, OpenSSL::Digest::SHA256.new), key ]
|
86
|
+
end
|
58
87
|
end
|
59
88
|
|
60
89
|
def build_root_ca
|
Binary file
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.2.
|
1
|
+
5.2.4
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-tcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,17 +103,31 @@ dependencies:
|
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - "<"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
108
|
+
version: 7.0.0
|
109
|
+
name: logstash-core
|
110
|
+
prerelease: false
|
111
|
+
type: :runtime
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "<"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 7.0.0
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '1.0'
|
109
123
|
name: logstash-devutils
|
110
124
|
prerelease: false
|
111
125
|
type: :development
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
114
|
-
- - "
|
128
|
+
- - "~>"
|
115
129
|
- !ruby/object:Gem::Version
|
116
|
-
version: '0'
|
130
|
+
version: '1.0'
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
132
|
requirement: !ruby/object:Gem::Requirement
|
119
133
|
requirements:
|
@@ -164,7 +178,7 @@ files:
|
|
164
178
|
- logstash-input-tcp.gemspec
|
165
179
|
- spec/inputs/tcp_spec.rb
|
166
180
|
- spec/spec_helper.rb
|
167
|
-
- vendor/jar-dependencies/org/logstash/inputs/
|
181
|
+
- vendor/jar-dependencies/org/logstash/inputs/plugin/5.2.4/plugin-5.2.4.jar
|
168
182
|
- version
|
169
183
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
170
184
|
licenses:
|
@@ -188,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
202
|
- !ruby/object:Gem::Version
|
189
203
|
version: '0'
|
190
204
|
requirements: []
|
191
|
-
|
192
|
-
rubygems_version: 2.6.13
|
205
|
+
rubygems_version: 3.1.6
|
193
206
|
signing_key:
|
194
207
|
specification_version: 4
|
195
208
|
summary: Reads events from a TCP socket
|