Open unverified-contact opened 5 years ago
Okay, some notes regarding my findings on this and what solution I went with.
I ended up downloading and specifying the CA Cert file from Mozilla You can find them here:
https://curl.haxx.se/ca/cacert.pem <--- this link should always be the latest one
More information on that file: https://curl.haxx.se/docs/caextract.html
I need to caution as a caveat, I'm very inexperienced with SSL. I don't know the full implications for security that this might entail with regards to someone else's application but for my purposes it works fine.
My guess (but I am not totally sure) is that the code I mentioned in my prior comment makes an assumption that a CA Cert file will be provided here because it may be considered best practice, for security purposes, to explicitly source and provide such a file.
I am trying to be able to establish a connection to a broker while using SASL_SSL without using SSL Client Certificate Auth.
Firstly, I'll explain that I'm new to Kafka so I have tried to be as absolutely detailed as possible here so there should be little confusion by the end of this.
This would be connection to my broker which would work without supplying this information in the configuration: (as taken from the example at https://github.com/weiboad/kafka-php/blob/master/example/Producer.php)
I don't want to be using this CA functionality nor am I looking to provide SSL credentials. Here's what I'm trying... Not sure if I'm doing it quite right but here was my attempt:
So when I try to run the above code, I get a bunch of errors:
In the code path taken here
stream_socket_client()
throws a Warning because it was given a$context
earlier, which seems to have expected that the cert related values are set. SeecreateStream()
insrc/CommonSocket.php
https://github.com/weiboad/kafka-php/blob/a8f5b01d9ca24c183b121d624e3402bf8aa70488/src/CommonSocket.php#L126... but in my case I don't even want to be using those so I hadn't set them. So they are populated with empty or otherwise invalid defaults, causing the errors we see later.
Now, I am able to workaround this problem very simply, and get the producer working exactly as I'd expect, by changing the
createSocket()
function to work like this:This change will result in no errors and a producer that seems to work exactly the way I'm trying for. By not passing in the context with the above details, the connection seems to work perfectly... At least in that the message successfully gets written to the broker.
I realise it's not relevant to this particular repo however I have been able to get the producer functioning in NodeJS with the
kafka-node
library this way... It's pretty straightforward so I'm including it just for reference to show how the connection is made without the CA stuff and without SSL credentials being specified:For my broker, I'm also able to use kafkacat without specifying these additional details either like this:
So my questions now are... is this is a bug? Or am I doing something wrong in my setup? Is this library even intended to work to support the connection I'd like? And if not, is that because it's considered bad practice or something like that? At bare minimum I wanted raise this as an issue because it really seems like with some minor changes this could easily support what I'm trying to do right out of the box without any changes to the lib but I don't have the familiarity to assert with confidence that I haven't done anything wrong here.