Double-bang requests with rfc9421 and cavage after on error
All checks were successful
/ docker (push) Successful in 4m20s
All checks were successful
/ docker (push) Successful in 4m20s
This commit is contained in:
parent
3f4f1fd9d2
commit
6f2686e0d3
2 changed files with 29 additions and 10 deletions
|
@ -33,9 +33,7 @@ Links for home:
|
|||
func RequestSignedRFC9421(
|
||||
method, target string,
|
||||
body []byte,
|
||||
keyId string,
|
||||
privateKeyBytes []byte,
|
||||
useEd bool,
|
||||
actor *models.User,
|
||||
) (*http.Response, error) {
|
||||
req, err := http.NewRequest(method, target, bytes.NewBuffer(slices.Clone(body)))
|
||||
if err != nil {
|
||||
|
@ -46,7 +44,7 @@ func RequestSignedRFC9421(
|
|||
signerFields := httpsign.Headers("@request-target", "content-digest")
|
||||
if config.GlobalConfig.Experimental.UseEd25519Keys {
|
||||
signer, err = httpsign.NewEd25519Signer(
|
||||
privateKeyBytes,
|
||||
actor.PrivateKeyEd,
|
||||
httpsign.NewSignConfig(),
|
||||
signerFields,
|
||||
)
|
||||
|
@ -54,7 +52,7 @@ func RequestSignedRFC9421(
|
|||
return nil, err
|
||||
}
|
||||
} else {
|
||||
key, err := x509.ParsePKCS1PrivateKey(privateKeyBytes)
|
||||
key, err := x509.ParsePKCS1PrivateKey(actor.PrivateKeyRsa)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -63,9 +61,15 @@ func RequestSignedRFC9421(
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
clientConfig := httpsign.NewClientConfig().SetSigner(signer)
|
||||
if config.GlobalConfig.Experimental.UseEd25519Keys {
|
||||
clientConfig = clientConfig.SetSignatureName("sig-ed")
|
||||
} else {
|
||||
clientConfig = clientConfig.SetSignatureName("sig-rsa")
|
||||
}
|
||||
client := httpsign.NewClient(
|
||||
RequestClient,
|
||||
httpsign.NewClientConfig().SetSigner(signer).SetSignatureName("sig1"),
|
||||
clientConfig,
|
||||
)
|
||||
res, err := client.Do(req)
|
||||
return res, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue