Skip to content

Commit

Permalink
add getVaultPubKey
Browse files Browse the repository at this point in the history
  • Loading branch information
markwirth-mw committed Aug 29, 2024
1 parent 283f327 commit 7553e09
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ type SSHSignResponse struct {
} `json:"data"`
}

type SSHReadPubKeyResponse struct {
LeaseID string `json:"lease_id"`
Renewable bool `json:"renewable"`
LeaseDuration int `json:"lease_duration"`
Data struct {
PublicKey string `json:"public_key"`
} `json:"data"`
}

func (k *SSH) Sign(role string, sshopts SSHSignOptions) (*SSHSignResponse, error) {
response := &SSHSignResponse{}
err := k.client.Write(
Expand All @@ -49,3 +58,20 @@ func (k *SSH) Sign(role string, sshopts SSHSignOptions) (*SSHSignResponse, error

return response, nil
}

func (k *SSH) GetVaultPubKey() (string, error) {
response := &SSHReadPubKeyResponse{}
err := k.client.Read(
[]string{
"v1",
k.MountPoint,
"config",
"ca",
}, response, nil,
)
if err != nil {
return "", err
}

return response.Data.PublicKey, nil
}

0 comments on commit 7553e09

Please sign in to comment.