jtriley / StarCluster

StarCluster is an open source cluster-computing toolkit for Amazon's Elastic Compute Cloud (EC2).
http://star.mit.edu/cluster
GNU Lesser General Public License v3.0
582 stars 313 forks source link

Generate SSL certificate for IPython Cluster Plugin #416

Open craigbruce opened 10 years ago

craigbruce commented 10 years ago

Using 0.95.5 on a VPC I have been struggling to get the IPython Cluster plugin to work I get this error:

>>> Creating SSL certificate for user sgeadmin
!!! ERROR - Error occured while running plugin 'ipcluster':
!!! ERROR - remote command 'source /etc/profile && openssl req -new
!!! ERROR - -newkey rsa:4096 -days 365 -nodes -x509 -subj
!!! ERROR - /C=US/ST=SC/L=STAR/O=Dis/CN= -keyout
!!! ERROR - /home/sgeadmin/.ipython/profile_default/sgeadmin.pem -out
!!! ERROR - /home/sgeadmin/.ipython/profile_default/sgeadmin.pem' failed
!!! ERROR - with status 1:
!!! ERROR - Generating a 4096 bit RSA private key
!!! ERROR - ............................................................
!!! ERROR - ....................................++
!!! ERROR - ............................................................
!!! ERROR - ...........................................++
!!! ERROR - writing new private key to
!!! ERROR - '/home/sgeadmin/.ipython/profile_default/sgeadmin.pem'
!!! ERROR - -----
!!! ERROR - end of string encountered while processing type of subject
!!! ERROR - name element #4
!!! ERROR - problems making Certificate Request

This is using a Ubuntu 12.04 x64 image. If I log manually I can run it if I change the -subj value to either -subj /C=US/ST=SC/L=STAR/O=Dis/CN=/ or -subj /C=US/ST=SC/L=STAR/O=Dis/. The version of OpenSSL is OpenSSL 1.0.1 14 Mar 2012. I tried the same command on my Mac (using OpenSSL 0.9.8y 5 Feb 2013) and get the same string handling error unless I use one of the above variations.

Have I overlooked something? For our purposes we don't need a self-signed SSL certificate since we access our cluster via VPN to a private VPC (not EC2-Classic). Maybe we can just disable it?

craigbruce commented 10 years ago

My coworker informs me the same setup works fine when he uses EC2-Classic, so it is possible this is because we run within VPC with PUBLIC_IPS=False

cancan101 commented 9 years ago

I am having the same issue.

cancan101 commented 9 years ago

This is what I use as a fix:

diff --git a/starcluster/plugins/ipcluster.py b/starcluster/plugins/ipcluster.py
index 7f74e68..a318eb6 100644
--- a/starcluster/plugins/ipcluster.py
+++ b/starcluster/plugins/ipcluster.py
@@ -221,7 +221,8 @@ class IPCluster(DefaultClusterSetup):
         ssl_cert = posixpath.join(profile_dir, '%s.pem' % user)
         if not master.ssh.isfile(user_cert):
             log.info("Creating SSL certificate for user %s" % user)
-            ssl_subj = "/C=US/ST=SC/L=STAR/O=Dis/CN=%s" % master.dns_name
+            dns_name = master.dns_name or '/'
+            ssl_subj = "/C=US/ST=SC/L=STAR/O=Dis/CN=%s" % dns_name
             master.ssh.execute(
                 "openssl req -new -newkey rsa:4096 -days 365 "
                 '-nodes -x509 -subj %s -keyout %s -out %s' %

The log of of the IPython notebook URL is wrong however:

>>> IPython notebook URL: https://:8888

This seems to be caused by master.dns_name being empty.