@ -7,6 +7,8 @@ import (
"crypto/x509"
"crypto/x509"
"encoding/hex"
"encoding/hex"
"log"
"log"
"os"
"strings"
"sync"
"sync"
"time"
"time"
@ -23,7 +25,6 @@ import (
casapi "github.com/smallstep/certificates/cas/apiv1"
casapi "github.com/smallstep/certificates/cas/apiv1"
"github.com/smallstep/certificates/db"
"github.com/smallstep/certificates/db"
"github.com/smallstep/certificates/kms"
"github.com/smallstep/certificates/kms"
"github.com/smallstep/certificates/kms/apiv1"
kmsapi "github.com/smallstep/certificates/kms/apiv1"
kmsapi "github.com/smallstep/certificates/kms/apiv1"
"github.com/smallstep/certificates/kms/sshagentkms"
"github.com/smallstep/certificates/kms/sshagentkms"
"github.com/smallstep/certificates/templates"
"github.com/smallstep/certificates/templates"
@ -336,13 +337,19 @@ func (a *Authority) init() error {
return err
return err
}
}
if km , ok := a . keyManager . ( apiv1 . Decrypter ) ; ok {
// TODO: this is not exactly nice to do, but ensures that tests will still run while
options . Decrypter , err = km . CreateDecrypter ( & kmsapi . CreateDecrypterRequest {
// ECDSA keys are in the testdata. ECDSA keys are no crypto.Decrypters, resulting
DecryptionKey : a . config . IntermediateKey ,
// in many errors in the test suite. Needs a better solution, I think.
Password : [ ] byte ( a . config . Password ) ,
underTest := strings . HasSuffix ( os . Args [ 0 ] , ".test" )
} )
if ! underTest {
if err != nil {
if km , ok := a . keyManager . ( kmsapi . Decrypter ) ; ok {
return err
options . Decrypter , err = km . CreateDecrypter ( & kmsapi . CreateDecrypterRequest {
DecryptionKey : a . config . IntermediateKey ,
Password : [ ] byte ( a . config . Password ) ,
} )
if err != nil {
return err
}
}
}
}
}
}
}
@ -500,7 +507,7 @@ func (a *Authority) init() error {
// Check if a KMS with decryption capability is required and available
// Check if a KMS with decryption capability is required and available
if a . requiresDecrypter ( ) {
if a . requiresDecrypter ( ) {
if _ , ok := a . keyManager . ( apiv1 . Decrypter ) ; ! ok {
if _ , ok := a . keyManager . ( kms api. Decrypter ) ; ! ok {
return errors . New ( "keymanager doesn't provide crypto.Decrypter" )
return errors . New ( "keymanager doesn't provide crypto.Decrypter" )
}
}
}
}