Skip to content

Modified connect method so tls.connect options can be supplied.#1

Merged
squaremo merged 1 commit intoamqp-node:masterfrom
esk525:tls_options
Jun 13, 2013
Merged

Modified connect method so tls.connect options can be supplied.#1
squaremo merged 1 commit intoamqp-node:masterfrom
esk525:tls_options

Conversation

@esk525
Copy link
Contributor

@esk525 esk525 commented Jun 12, 2013

To connect with tls using certificates, one needs to pass the options such as key, cert, and ca.

I modified the connect method slightly to allow passing those options to tls.connect.

I also modified the listen event to listen for the event 'secureConnect' as defined in the tls documentation.

I hope you find this useful. Thanks for the great libraries.

@squaremo squaremo merged commit 8e25be5 into amqp-node:master Jun 13, 2013
@squaremo
Copy link
Collaborator

Thank you muchly for the pull request. I wrote a small example. Would you try it out? It's in master.

@esk525
Copy link
Contributor Author

esk525 commented Jun 14, 2013

Thank you. Yes. I will test the example this evening after work.

On Thu, Jun 13, 2013 at 6:57 PM, Michael Bridgen
[email protected]:

Thank you muchly for the pull request. I wrote a small example. Would you
try it out? It's in master.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1#issuecomment-19430402
.

@esk525 esk525 deleted the tls_options branch June 18, 2013 12:01
@esk525
Copy link
Contributor Author

esk525 commented Jun 18, 2013

Sorry for the delay in response. Yes, everything worked great, thank you.

@squaremo
Copy link
Collaborator

Great stuff!

By the way, I wrote a guide to using SSL for the docs: http://squaremo.github.io/amqp.node/doc/ssl.html.
I am thinking that a table with "What do you want to achieve?" v "Here are the settings" might be useful, what do you think?

@esk525
Copy link
Contributor Author

esk525 commented Jun 18, 2013

Awesome write up. I think the table for "What you want to achieve" is a
good idea.

I will add one thing to what you wrote. I encountered the [Error:
SELF_SIGNED_CERT_IN_CHAIN] on my client (running on Windows 7). I am
pretty sure I have supplied the correct ca, but I could have made a mistake
as it has been a while since I pulled the ca cert from the server. I used
the tls option "rejectUnauthorized: false", and the connection was made.

In my case, what I want is a secure connection from client to server, with
a fixed IP address, and on the server side I want to verify the client
certificate (i.e. only allow connections from certs that I've issued).
While using this option works in this case, I think it would open up the
clients to a man-in-the-middle attack. Do you agree?

On Tue, Jun 18, 2013 at 8:51 AM, Michael Bridgen
[email protected]:

Great stuff!

By the way, I wrote a guide to using SSL for the docs:
http://squaremo.github.io/amqp.node/doc/ssl.html.
I am thinking that a table with "What do you want to achieve?" v "Here are
the settings" might be useful, what do you think?


Reply to this email directly or view it on GitHubhttps://github.com//pull/1#issuecomment-19608890
.

@squaremo
Copy link
Collaborator

Quite right, you definitely do not want to use rejectUnauthorized: false if you're using certificates at all. I ought to make a note of that in the guide.

With respect to the self-signed cert problem, there's a couple of things I'd check: one is that you are supplying the certificate of the CA that has signed the server certificate (it has tripped me up before, especially when regenerating certificates during trial runs); another is that you can connect, with the same set of files, using s_client. Something like

openssl s_client -connect localhost:5671 -cert client/cert.pem -key client/key.pem \
                        -pass pass:MySecret -CAFile testca/cacert.pem -showcerts

OpenSSL will tell you if there's a problem and show you the certificates in ASCII armour so you can check them against the files.

@esk525
Copy link
Contributor Author

esk525 commented Jun 18, 2013

You are exactly right, I had grabbed the server certificate and not the
signing certificate by mistake.

Now I am just dealing with the Hostname/IP not matching even though I've
added the hostname used in the cert to my hosts file.

Thanks.

On Tue, Jun 18, 2013 at 10:18 AM, Michael Bridgen
[email protected]:

Quite right, you definitely do not want to use rejectUnauthorized: falseif you're using certificates at all. I ought to make a note of that in the
guide.

With respect to the self-signed cert problem, there's a couple of things
I'd check: one is that you are supplying the certificate of the CA that has
signed the server certificate (it has tripped me up before, especially
when regenerating certificates during trial runs); another is that you can
connect, with the same set of files, using s_client. Something like

openssl s_client -connect localhost:5671 -cert client/cert.pem -key client/key.pem
-pass pass:MySecret -CAFile testca/cacert.pem -showcerts

OpenSSL will tell you if there's a problem and show you the certificates
in ASCII armour so you can check them against the files.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1#issuecomment-19614035
.

@esk525
Copy link
Contributor Author

esk525 commented Jun 18, 2013

Got it... had to use the right domain name. Thanks.

On Tue, Jun 18, 2013 at 10:25 AM, Edward Kline [email protected] wrote:

You are exactly right, I had grabbed the server certificate and not the
signing certificate by mistake.

Now I am just dealing with the Hostname/IP not matching even though I've
added the hostname used in the cert to my hosts file.

Thanks.

On Tue, Jun 18, 2013 at 10:18 AM, Michael Bridgen <
[email protected]> wrote:

Quite right, you definitely do not want to use rejectUnauthorized:
false if you're using certificates at all. I ought to make a note of
that in the guide.

With respect to the self-signed cert problem, there's a couple of things
I'd check: one is that you are supplying the certificate of the CA that has
signed the server certificate (it has tripped me up before, especially
when regenerating certificates during trial runs); another is that you can
connect, with the same set of files, using s_client. Something like

openssl s_client -connect localhost:5671 -cert client/cert.pem -key client/key.pem
-pass pass:MySecret -CAFile testca/cacert.pem -showcerts

OpenSSL will tell you if there's a problem and show you the certificates
in ASCII armour so you can check them against the files.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1#issuecomment-19614035
.

cressie176 pushed a commit that referenced this pull request Nov 1, 2022
@cressie176 cressie176 mentioned this pull request Sep 2, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants