@@ -37,13 +37,13 @@ type KmsSigner struct {
3737
3838// region and keyAlias must be valid, eg. us-west-1 alias/mytestkey
3939// if awsKey, awsSec are empty string, will use aws sdk auto search
40- func NewKmsSigner (region , keyAlias , awsKey , awsSec , profile string , chainId * big.Int ) (* KmsSigner , error ) {
40+ func NewKmsSigner (region , keyAlias , awsKey , awsSec string , chainId * big.Int ) (* KmsSigner , error ) {
4141 cfg := & aws.Config {
4242 Region : aws .String (region ),
4343 }
4444
45- if profile != " " {
46- cfg .Credentials = credentials .NewSharedCredentials ("" , profile )
45+ if awsKey == "profile " {
46+ cfg .Credentials = credentials .NewSharedCredentials ("" , awsSec )
4747 } else if awsKey != "" && awsSec != "" {
4848 cfg .Credentials = credentials .NewStaticCredentials (awsKey , awsSec , "" )
4949 } else {
@@ -188,8 +188,10 @@ func padBigInt(i *big.Int) []byte {
188188// passphrase will be awsKey:awsSec or if empty, will use aws auto search env variable etc
189189// otherwise normal ks json file based signer
190190const awskmsPre = "awskms:"
191+ const awsCreProfilePre = "profile"
191192
192193// return signer, address
194+ // if use profile, passphrase should be "profile:default" or "profile:xxx"
193195func CreateSigner (ksfile , passphrase string , chainid * big.Int ) (Signer , common.Address , error ) {
194196 if strings .HasPrefix (ksfile , awskmsPre ) {
195197 kmskeyinfo := strings .SplitN (ksfile , ":" , 3 )
@@ -203,7 +205,8 @@ func CreateSigner(ksfile, passphrase string, chainid *big.Int) (Signer, common.A
203205 return nil , common.Address {}, fmt .Errorf ("%s has wrong format, expected '<awsKey>:<awsSecret>'" , passphrase )
204206 }
205207 }
206- kmsSigner , err := NewKmsSigner (kmskeyinfo [1 ], kmskeyinfo [2 ], awskeysec [0 ], awskeysec [1 ], "" , chainid )
208+
209+ kmsSigner , err := NewKmsSigner (kmskeyinfo [1 ], kmskeyinfo [2 ], awskeysec [0 ], awskeysec [1 ], chainid )
207210 if err != nil {
208211 return nil , common.Address {}, err
209212 }
0 commit comments