Skip to content

Commit e587b3d

Browse files
committed
generate unique paths for complement certs to go in
Signed-off-by: June Clementine Strawberry <june@3.dog>
1 parent 1502a00 commit e587b3d

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

federation/server.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,18 @@ func federationServer(cfg *config.Complement, h http.Handler) (*http.Server, str
547547
Addr: ":8448",
548548
Handler: h,
549549
}
550-
tlsCertPath := path.Join(os.TempDir(), "complement.crt")
551-
tlsKeyPath := path.Join(os.TempDir(), "complement.key")
552-
certificateDuration := time.Hour
553-
priv, err := rsa.GenerateKey(rand.Reader, 4096)
550+
dirNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
551+
dirNumber, err := rand.Int(rand.Reader, dirNumberLimit)
552+
if err != nil {
553+
return nil, "", "", err
554+
}
555+
556+
os.MkdirAll(path.Join(os.TempDir(), dirNumber.String()), 0777)
557+
558+
tlsCertPath := path.Join(os.TempDir(), dirNumber.String(), "/", "complement.crt")
559+
tlsKeyPath := path.Join(os.TempDir(), dirNumber.String(), "/", "complement.key")
560+
certificateDuration := time.Hour * 48
561+
priv, err := rsa.GenerateKey(rand.Reader, 2048)
554562
if err != nil {
555563
return nil, "", "", err
556564
}

0 commit comments

Comments
 (0)