Skip to content

Commit

Permalink
Merge pull request #28 from markwirth-mw/ssh-key_signing
Browse files Browse the repository at this point in the history
add getVaultPubKey
  • Loading branch information
Lucaber authored Aug 29, 2024
2 parents 0213c0b + 7553e09 commit 4c44afb
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 4c44afb

Please sign in to comment.