SSL support in mgo

1,075 views
Skip to first unread message

Tom de Grunt

unread,
May 14, 2014, 4:08:04 PM5/14/14
to mgo-...@googlegroups.com
Hi,

Having a hard time finding out wether mgo supports ssl connections with mongodb.
So say I'm configuring SSL for mongodb (http://docs.mongodb.org/manual/tutorial/configure-ssl/) - can I still connect with mgo?

If so how? Would it be like PyMongo's connection options: mongodb://mongodb.example.net:27017/?ssl=true ?

The SSL option is not mentioned in http://godoc.org/labix.org/v2/mgo#Dial ... 

Thanks,
Tom

Gustavo Niemeyer

unread,
May 16, 2014, 1:27:53 PM5/16/14
to mgo-...@googlegroups.com
Hi Tom,

To connect to an SSL-enabled MongoDB, just define the DialServer
function in mgo.DialInfo [1], and make use of the tls.Dial [2] to
perform the connection.

Please let me know if you need any further details.

[1] http://labix.org/v2/mgo#DialInfo
[2] http://golang.org/pkg/crypto/tls#Dial
> --
> You received this message because you are subscribed to the Google Groups
> "mgo-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mgo-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

gustavo @ http://niemeyer.net

Tom de Grunt

unread,
Jun 5, 2014, 6:07:44 PM6/5/14
to mgo-...@googlegroups.com
Hi Gustavo,

Late reply, but thanks for this, exactly what I needed!
Got it to work!

Cheers,
Tom

Omkar Patil

unread,
Mar 8, 2015, 9:24:37 AM3/8/15
to mgo-...@googlegroups.com
Hello Gustavo,

I am trying to use above mentioned method. I am having following error with mongodb 3.0
SSL: error:14094412:SSL routines:SSL3_READ_BYTES:sslv3 alert bad certificate
Is it somehow related to https://jira.mongodb.org/browse/MGO-14 ?

Kindly help.

Regards,
Omkar

Gustavo Niemeyer

unread,
Mar 9, 2015, 2:46:44 PM3/9/15
to mgo-...@googlegroups.com
Hey Omkar,

It's hard to tell what you've got there just from that message. It's just complaining that it has observed a bad certificate, which could mean exactly that.

Issue MGO-14 was about being unable to turn on hostname verification, and that's been fixed via the new DialServer field of DialInfo. That's been released a while ago, so I'd surely suggest using it.

Otherwise, I suggest performing further testing and investigation, to pin down what that message actually means.

 

Omkar Patil

unread,
Mar 27, 2015, 3:11:27 AM3/27/15
to mgo-...@googlegroups.com
Thanks Gustavo,

It was my mistake. I was using wrong certificates. And I am sorry I couldn't reply any sooner. Your support has been extremely valuable to me and my team.

Regards,
Omkar

You received this message because you are subscribed to a topic in the Google Groups "mgo-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mgo-users/44Uy4dc6o00/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mgo-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages