File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,12 @@ package tls
1818import (
1919 "bufio"
2020 "crypto"
21+ "crypto/rand"
2122 "fmt"
22- pwr "math/rand"
2323 "os"
2424 "path"
2525 "path/filepath"
2626 "strings"
27- "time"
2827
2928 "crypto/sha512"
3029 "crypto/x509"
@@ -677,13 +676,13 @@ func addCertificatesToCMSKeystore(cmsKeystore *KeyStoreData) error {
677676
678677// generateRandomPassword generates a random 12 character password from the characters a-z, A-Z, 0-9
679678func generateRandomPassword () * sensitive.Sensitive {
680- pwr .Seed (time .Now ().Unix ())
681679 validChars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
682680 validcharArray := []byte (validChars )
683- password := []byte {}
681+ password := make ([]byte , 12 )
682+ _ , _ = rand .Read (password ) // Errors are never returned from crypto/rand.Read()
683+
684684 for i := 0 ; i < 12 ; i ++ {
685- // #nosec G404 - this is only for internal keystore and using math/rand pose no harm.
686- password = append (password , validcharArray [pwr .Intn (len (validcharArray ))])
685+ password [i ] = validcharArray [int (password [i ])% len (validcharArray )]
687686 }
688687
689688 return sensitive .New (password )
You can’t perform that action at this time.
0 commit comments