func initKeys(a *AuthServer, dataDir string, id IdentityID) (*Identity, error) {
	kp, cp := keysPath(dataDir, id)

	keyExists, err := pathExists(kp)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	certExists, err := pathExists(cp)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	if !keyExists || !certExists {
		privateKey, publicKey, err := a.GenerateKeyPair("")
		if err != nil {
			return nil, trace.Wrap(err)
		}
		cert, err := a.GenerateHostCert(publicKey, id.HostUUID, a.DomainName, teleport.Roles{id.Role}, 0)
		if err != nil {
			return nil, trace.Wrap(err)
		}
		if err := writeKeys(dataDir, id, privateKey, cert); err != nil {
			return nil, trace.Wrap(err)
		}
	}
	i, err := ReadIdentity(dataDir, id)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return i, nil
}
// initKeys initializes this node's host certificate signed by host authority
initKeys initializes this node's host certificate signed by host authority
// initKeys initializes this node ' s host certificate signed by host authority
func initKeys(a *AuthServer, dataDir string, id IdentityID) (*Identity, error) {
	kp, cp := keysPath(dataDir, id)
	keyExists, err := pathExists(kp)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	certExists, err := pathExists(cp)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	if !keyExists || !certExists {
		privateKey, publicKey, err := a.GenerateKeyPair("")
		if err != nil {
			return nil, trace.Wrap(err)
		}
		cert, err := a.GenerateHostCert(publicKey, id.HostUUID, a.DomainName, teleport.Roles{id.Role}, 0)
		if err != nil {
			return nil, trace.Wrap(err)
		}
		if err := writeKeys(dataDir, id, privateKey, cert); err != nil {
			return nil, trace.Wrap(err)
		}
	}
	i, err := ReadIdentity(dataDir, id)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return i, nil
}
func initKeys ( a * AuthServer , dataDir string , id IdentityID ) ( * Identity , error ) { kp , cp := keysPath ( dataDir , id ) keyExists , err := pathExists ( kp ) if err != nil { return nil , trace . Wrap ( err ) } certExists , err := pathExists ( cp ) if err != nil { return nil , trace . Wrap ( err ) } if ! keyExists || ! certExists { privateKey , publicKey , err := a . GenerateKeyPair ( " " ) if err != nil { return nil , trace . Wrap ( err ) } cert , err := a . GenerateHostCert ( publicKey , id . HostUUID , a . DomainName , teleport . Roles { id . Role } , 0 ) if err != nil { return nil , trace . Wrap ( err ) } if err := writeKeys ( dataDir , id , privateKey , cert ) ; err != nil { return nil , trace . Wrap ( err ) } } i , err := ReadIdentity ( dataDir , id ) if err != nil { return nil , trace . Wrap ( err ) } return i , nil }
initKeys initializes this node's host certificate signed by host authority
initKeys initializes this node ' s host certificate signed by host authority