code: func NewConfig(torusRoot string) (*Config, error) {
  	preferences, err := prefs.NewPreferences()
  	if err != nil {
  		return nil, err
  	}
  
  	publicKey, err := prefs.LoadPublicKey(preferences)
  	if err != nil {
  		return nil, fmt.Errorf("failed to load public key")
  	}
  
  	caBundle, err := loadCABundle(preferences.Core.CABundleFile)
  	if err != nil {
  		return nil, err
  	}
  
  	registryURI, err := url.Parse(preferences.Core.RegistryURI)
  	if err != nil {
  		return nil, fmt.Errorf("invalid registry_uri")
  	}
  
  	manifestURI, err := url.Parse(preferences.Core.ManifestURI)
  	if err != nil {
  		return nil, fmt.Errorf("invalid manifest_uri")
  	}
  
  	_, _, err = net.SplitHostPort(preferences.Core.GatekeeperAddress)
  	if err != nil {
  		return nil, fmt.Errorf("invalid gatekeeper listener address")
  	}
  
  	cfg := &Config{
  		APIVersion: apiVersion,
  		Version:    Version,
  
  		TorusRoot:         torusRoot,
  		PidPath:           path.Join(torusRoot, "daemon.pid"),
  		GatekeeperPidPath: path.Join(torusRoot, "gateway.pid"),
  		DBPath:            path.Join(torusRoot, "daemon.db"),
  		LastUpdatePath:    path.Join(torusRoot, "last_update"),
  
  		RegistryURI:       registryURI,
  		ManifestURI:       manifestURI,
  		GatekeeperAddress: preferences.Core.GatekeeperAddress,
  		CABundle:          caBundle,
  		PublicKey:         publicKey,
  	}
  
  	// set OS specific transport address
  	setTransportAddress(cfg)
  
  	return cfg, nil
  }
docs: // NewConfig returns a new Config, with loaded user preferences.