-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforcing VERIFY_PEER
on the client
#5
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,2 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem "rspec" | ||
gem "insist" | ||
gem "stud" | ||
gem "fpm" | ||
gem "pleaserun" | ||
|
||
gem "jruby-openssl", :platform => :jruby | ||
gemspec |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# encoding: utf-8 | ||
require "lib/lumberjack/client" | ||
require "lib/lumberjack/server" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the 'lib/' part here |
||
require "stud/temporary" | ||
require "flores/pki" | ||
require "fileutils" | ||
require "thread" | ||
require "spec_helper" | ||
|
||
describe "A client" do | ||
let(:port) { Flores::Random.integer(1024..65335) } | ||
let(:csr) { Flores::PKI::CertificateSigningRequest.new } | ||
let(:key_bits) { 1024 } | ||
let(:key) { OpenSSL::PKey::RSA.generate(key_bits, 65537) } | ||
let(:certificate_duration) { Flores::Random.number(1..86400) } | ||
let(:certificate_subject) { "CN=server.example.com" } | ||
let(:certificate) { csr.create } | ||
let(:certificate_file_crt) { "certificate.crt" } | ||
let(:certificate_file_key) { "certificate.key" } | ||
let(:host) { "127.0.0.1" } | ||
let(:queue) { Queue.new } | ||
let(:payload) { {"line" => "hello world" } } | ||
|
||
before do | ||
csr.subject = certificate_subject | ||
csr.public_key = key.public_key | ||
csr.start_time = Time.now | ||
csr.expire_time = csr.start_time + certificate_duration | ||
csr.signing_key = key | ||
csr.want_signature_ability = true | ||
|
||
expect(File).to receive(:read).twice.with(certificate_file_crt) { certificate.to_s } | ||
expect(File).to receive(:read).with(certificate_file_key) { key.to_s } | ||
|
||
server = Lumberjack::Server.new(:port => port, | ||
:address => host, | ||
:ssl_certificate => certificate_file_crt, | ||
:ssl_key => certificate_file_key) | ||
|
||
Thread.new do | ||
server.run { |data| queue.push(data) } | ||
end | ||
end | ||
|
||
it "should require a certificate" do | ||
expect { | ||
client = Lumberjack::Client.new(:port => port, | ||
:host => host, | ||
:addresses => host, | ||
:ssl_certificate => certificate_file_crt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for a ssl_key parameter on the client side? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well the client use the public key to encrypt which is available in the certificate and the server use the private key to decrypt it? The ssl_key was never a requirement in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/elastic/logstash-forwarder/blob/master/publisher1.go#L137 I'll check on the ruby side, I am +1 on having the same behavior, I need to investigate what it's actually do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. http://www.hydrogen18.com/blog/your-own-pki-tls-golang.html A lot of nice information ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't currently require a client certificate, it's optional. |
||
|
||
client.write(payload) | ||
}.not_to raise_error | ||
|
||
expect(queue.pop).to eq(payload) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the 'lib/' part here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😞 by myself on that