     certInfo = yield readCertificateInfo this.body.certificate
     certInfo.data = this.body.certificate
     keystoreDoc.cert = certInfo
+    keystoreDoc.key = this.body.key
     yield Q.ninvoke keystoreDoc, 'save'
-
     #Add the new certficate to the keystore
     this.status = 201
     logger.info 'Server certificate created'
+
   catch err
     utils.logAndSetResponse this, 'internal server error', "Could not create a client cert via the API: #{err}", 'error'
+
+  this.body
 
 
 createCertificate = (options) ->

    logger.info 'Client certificate created'
  catch err
    utils.logAndSetResponse this, 'internal server error', "Could not create a client cert via the API: #{err}", 'error'

generateServerCert = (options) ->
  keystoreDoc = yield Keystore.findOne().exec()

  options = this.request.body
  if options.type is 'server'
    logger.info 'Generating server cert'
    result = yield generateServerCert options
  else
    logger.info 'Generating client cert'
    result = yield generateClientCert options
  this.status = 201
  this.body = result

generateClientCert = (options) ->
  keystoreDoc = yield Keystore.findOne().exec()
