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 @@ -17,12 +17,11 @@ package tls
1717
1818import (
1919 "bufio"
20+ "crypto/rand"
2021 "fmt"
21- pwr "math/rand"
2222 "os"
2323 "path/filepath"
2424 "strings"
25- "time"
2625
2726 "crypto/sha512"
2827 "crypto/x509"
@@ -596,13 +595,13 @@ func addCertificatesToCMSKeystore(cmsKeystore *KeyStoreData) error {
596595
597596// generateRandomPassword generates a random 12 character password from the characters a-z, A-Z, 0-9
598597func generateRandomPassword () * sensitive.Sensitive {
599- pwr .Seed (time .Now ().Unix ())
600598 validChars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
601599 validcharArray := []byte (validChars )
602- password := []byte {}
600+ password := make ([]byte , 12 )
601+ _ , _ = rand .Read (password ) // Errors are never returned from crypto/rand.Read()
602+
603603 for i := 0 ; i < 12 ; i ++ {
604- // #nosec G404 - this is only for internal keystore and using math/rand pose no harm.
605- password = append (password , validcharArray [pwr .Intn (len (validcharArray ))])
604+ password [i ] = validcharArray [int (password [i ])% len (validcharArray )]
606605 }
607606
608607 return sensitive .New (password )
You can’t perform that action at this time.
0 commit comments