@@ -1043,18 +1043,36 @@ def certs_add(self, args):
10431043 """
10441044 Binds a certificate/key pair to an application.
10451045
1046- Usage: deis certs:add <cert> <key>
1046+ Usage: deis certs:add <cert> <key> [options]
10471047
10481048 Arguments:
10491049 <cert>
10501050 The public key of the SSL certificate.
10511051 <key>
10521052 The private key of the SSL certificate.
1053+
1054+ Options:
1055+ --common-name=<cname>
1056+ The common name of the certificate. If none is provided, the controller will
1057+ interpret the common name from the certificate.
1058+ --subject-alt-names=<sans>
1059+ The subject alternate names (SAN) of the certificate, separated by commas. This will
1060+ create multiple Certificate objects in the controller, one for each SAN.
10531061 """
10541062 cert = args .get ('<cert>' )
10551063 key = args .get ('<key>' )
1064+ self ._certs_add (cert , key , args .get ('--common-name' ))
1065+ sans = args .get ('--subject-alt-names' )
1066+ if sans :
1067+ [self ._certs_add (cert , key , san ) for san in sans .split (',' )]
1068+
1069+ def _certs_add (self , cert , key , common_name = None ):
10561070 body = {'certificate' : file (cert ).read ().strip (), 'key' : file (key ).read ().strip ()}
1057- sys .stdout .write ("Adding SSL endpoint... " )
1071+ if common_name :
1072+ body ['common_name' ] = common_name
1073+ sys .stdout .write ("Adding SSL endpoint {}..." .format (common_name ))
1074+ else :
1075+ sys .stdout .write ("Adding SSL endpoint... " )
10581076 sys .stdout .flush ()
10591077 try :
10601078 progress = TextProgress ()
@@ -1066,7 +1084,8 @@ def certs_add(self, args):
10661084 if response .status_code == requests .codes .created :
10671085 self ._logger .info ("done" )
10681086 data = response .json ()
1069- self ._logger .info ("{common_name}" .format (** data ))
1087+ if not common_name :
1088+ self ._logger .info ("{common_name}" .format (** data ))
10701089 else :
10711090 raise ResponseError (response )
10721091
0 commit comments