server/boot/load-model.js
function(seriesCallback) {
      var modelname = 'tlsprofile';
      async.forEachOf(
        apicCfg['tls-profiles'],
        function(profile, name, asyncCB) {
          var instance = {
            'snapshot-id': uid,
            'org-id': defaultOrg.id,
            id: 'defaultTlsProfile-' + name,
            name: name,
            public: false,
            ciphers: [
              'SSL_RSA_WITH_AES_256_CBC_SHA',
              'SSL_RSA_WITH_AES_128_CBC_SHA',
              'SSL_RSA_WITH_3DES_EDE_CBC_SHA',
              'SSL_RSA_WITH_RCA_128_SHA',
              'SSL_RSA_WITH_RCA_128_MD5' ],
            protocols: [ 'TLSv11', 'TLSv12' ],
            certs: [],
            'mutual-auth': false };

          if (profile.rejectUnauthorized === true) {
            instance['mutual-auth'] = true;
          }

          if (Array.isArray(profile.secureProtocols)) {
            instance.protocols = [];
            profile.secureProtocols.forEach(function(protocol) {
              switch (protocol) {
                case 'TLSv1_method':
                  instance.protocols.push('TLSv1');
                  break;
                case 'TLSv1_1_method':
                  instance.protocols.push('TLSv11');
                  break;
                case 'TLSv1_2_method':
                  instance.protocols.push('TLSv12');
                  break;
              }
            });
          }

          if (typeof profile.key === 'object') {
            instance['private-key'] = profile.key.content;
          }

          if (typeof profile.cert === 'object') {
            instance.certs.push({
              name: profile.cert.name,
              cert: profile.cert.content,
              'cert-type': 'INTERMEDIATE',
              'cert-id': name + '-cert-' + profile.cert.name });
          }

          if (Array.isArray(profile.ca)) {
            profile.ca.forEach(function(ca) {
              if (typeof ca === 'object') {
                instance.certs.push({
                  name: ca.name,
                  cert: ca.content,
                  'cert-type': 'CLIENT',
                  'cert-id': name + '-ca-cert-' + ca.name });
              }
            });
          }

          app.models[modelname].create(
            instance,
            function(err, mymodel) {
              if (err) {
                logger.error('Failed to populate a tls-profile:', err);
              } else {
                logger.debug('%s created: %j', modelname, mymodel);
              }
              asyncCB();
            });
        });

      seriesCallback();
    }
function(seriesCallback) {
      var modelname = 'tlsprofile';
      async.forEachOf(
        apicCfg['tls-profiles'],
        function(profile, name, asyncCB) {
          var instance = {
            'snapshot-id': uid,
            'org-id': defaultOrg.id,
            id: 'defaultTlsProfile-' + name,
            name: name,
            public: false,
            ciphers: [
              'SSL_RSA_WITH_AES_256_CBC_SHA',
              'SSL_RSA_WITH_AES_128_CBC_SHA',
              'SSL_RSA_WITH_3DES_EDE_CBC_SHA',
              'SSL_RSA_WITH_RCA_128_SHA',
              'SSL_RSA_WITH_RCA_128_MD5' ],
            protocols: [ 'TLSv11', 'TLSv12' ],
            certs: [],
            'mutual-auth': false };

          if (profile.rejectUnauthorized === true) {
            instance['mutual-auth'] = true;
          }

          if (Array.isArray(profile.secureProtocols)) {
            instance.protocols = [];
            profile.secureProtocols.forEach(function(protocol) {
              switch (protocol) {
                case 'TLSv1_method':
                  instance.protocols.push('TLSv1');
                  break;
                case 'TLSv1_1_method':
                  instance.protocols.push('TLSv11');
                  break;
                case 'TLSv1_2_method':
                  instance.protocols.push('TLSv12');
                  break;
              }
            });
          }

          if (typeof profile.key === 'object') {
            instance['private-key'] = profile.key.content;
          }

          if (typeof profile.cert === 'object') {
            instance.certs.push({
              name: profile.cert.name,
              cert: profile.cert.content,
              'cert-type': 'INTERMEDIATE',
              'cert-id': name + '-cert-' + profile.cert.name });
          }

          if (Array.isArray(profile.ca)) {
            profile.ca.forEach(function(ca) {
              if (typeof ca === 'object') {
                instance.certs.push({
                  name: ca.name,
                  cert: ca.content,
                  'cert-type': 'CLIENT',
                  'cert-id': name + '-ca-cert-' + ca.name });
              }
            });
          }

          app.models[modelname].create(
            instance,
            function(err, mymodel) {
              if (err) {
                logger.error('Failed to populate a tls-profile:', err);
              } else {
                logger.debug('%s created: %j', modelname, mymodel);
              }
              asyncCB();
            });
        });

      seriesCallback();
    }
function ( seriesCallback ) { var modelname = 'tlsprofile' ; async . forEachOf ( apicCfg [ 'tls-profiles' ] , function ( profile , name , asyncCB ) { var instance = { 'snapshot-id' : uid , 'org-id' : defaultOrg . id , id : 'defaultTlsProfile-' + name , name : name , public : false , ciphers : [ 'SSL_RSA_WITH_AES_256_CBC_SHA' , 'SSL_RSA_WITH_AES_128_CBC_SHA' , 'SSL_RSA_WITH_3DES_EDE_CBC_SHA' , 'SSL_RSA_WITH_RCA_128_SHA' , 'SSL_RSA_WITH_RCA_128_MD5' ] , protocols : [ 'TLSv11' , 'TLSv12' ] , certs : [ ] , 'mutual-auth' : false } ; if ( profile . rejectUnauthorized === true ) { instance [ 'mutual-auth' ] = true ; } if ( Array . isArray ( profile . secureProtocols ) ) { instance . protocols = [ ] ; profile . secureProtocols . forEach ( function ( protocol ) { switch ( protocol ) { case 'TLSv1_method' : instance . protocols . push ( 'TLSv1' ) ; break ; case 'TLSv1_1_method' : instance . protocols . push ( 'TLSv11' ) ; break ; case 'TLSv1_2_method' : instance . protocols . push ( 'TLSv12' ) ; break ; } } ) ; } if ( typeof profile . key === 'object' ) { instance [ 'private-key' ] = profile . key . content ; } if ( typeof profile . cert === 'object' ) { instance . certs . push ( { name : profile . cert . name , cert : profile . cert . content , 'cert-type' : 'INTERMEDIATE' , 'cert-id' : name + '-cert-' + profile . cert . name } ) ; } if ( Array . isArray ( profile . ca ) ) { profile . ca . forEach ( function ( ca ) { if ( typeof ca === 'object' ) { instance . certs . push ( { name : ca . name , cert : ca . content , 'cert-type' : 'CLIENT' , 'cert-id' : name + '-ca-cert-' + ca . name } ) ; } } ) ; } app . models [ modelname ] . create ( instance , function ( err , mymodel ) { if ( err ) { logger . error ( 'Failed to populate a tls-profile:' , err ) ; } else { logger . debug ( '%s created: %j' , modelname , mymodel ) ; } asyncCB ( ) ; } ) ; } ) ; seriesCallback ( ) ; }
5. create the "tls-profile" instances
5 . create the tls - profile instances