-
Notifications
You must be signed in to change notification settings - Fork 75
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
Fix SSL Subject regression in server mode #199
Fix SSL Subject regression in server mode #199
Conversation
af8540c
to
77c63f8
Compare
Alters the TCP#decode_buffer signature to accept the _ssl subject_ instead of expecting a ruby socket, so that it can be interoperable between the ruby-based client mode and the netty-powered server mode. In server mode, the SSL subject is extracted _once_ when initializing the connection IFF SSL is enabled and verification is turned on. Co-authored-by: Will Weber <[email protected]> Closes: logstash-plugins#159
77c63f8
to
9c643c8
Compare
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.
not sure what the old format was but it would be nice to use the same (RFC) format.
otherwise the formats are different (the RFC format is cleaner IMHO) :
- Ruby
"/OU=foo bar; please fix your client./CN=sample.name"
- Java
"CN=sample.name,OU=foo bar\\; please fix your client."
def extract_sslsubject(channel) | ||
return nil unless @tcp.ssl_enable && @tcp.ssl_verify | ||
|
||
channel.pipeline().get("ssl-handler").engine().getSession().getPeerPrincipal().getName() |
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.
channel.pipeline().get("ssl-handler").engine().getSession().getPeerPrincipal().getName() | |
channel.pipeline().get("ssl-handler").engine.getSession.getPeerCertificates[0].getSubjectX500Principal.getName |
return nil unless @tcp.ssl_enable && @tcp.ssl_verify | ||
|
||
channel.pipeline().get("ssl-handler").engine().getSession().getPeerPrincipal().getName() | ||
rescue Exception => e |
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.
let's not use the anti-pattern or rescuing everything
rescue Exception => e | |
rescue java.lang.Exception |
also might be worth logging the exception at least on the debug level
def handle_socket(socket) | ||
client_address = socket.peeraddr[3] | ||
client_ip_address = socket.peeraddr[2] | ||
client_port = socket.peeraddr[1] | ||
|
||
# Client mode sslsubject extraction, server mode happens in DecoderImpl#decode | ||
ssl_subject = socket.peer_cert.subject.to_s if @ssl_enable && @ssl_verify |
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.
ssl_subject = socket.peer_cert.subject.to_s if @ssl_enable && @ssl_verify | |
ssl_subject = socket.peer_cert.subject.to_s(OpenSSL::X509::Name::RFC2253) if @ssl_enable && @ssl_verify |
Alters the TCP#decode_buffer signature to accept the ssl subject instead of
expecting a ruby socket, so that it can be interoperable between the ruby-based
client mode and the netty-powered server mode.
In server mode, the SSL subject is extracted once when initializing the
connection IFF SSL is enabled and verification is turned on.
Co-authored-by: Will Weber [email protected]
Closes: #159