From b0ac91b4f633cdfe1835bcdb251ebd72b11be4c2 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 10 Nov 2021 14:36:26 +0100 Subject: [PATCH] security(core): rsa keys no more world readable (#165) --- gorgone/class/core.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gorgone/class/core.pm b/gorgone/class/core.pm index c21bf88..5e90e89 100644 --- a/gorgone/class/core.pm +++ b/gorgone/class/core.pm @@ -108,6 +108,15 @@ sub init_server_keys { $self->{logger}->writeLogInfo("[core] Public key file '$self->{config}->{configuration}->{gorgone}->{gorgonecore}->{pubkey}' written"); } + my $rv = chmod(0600, $self->{config}->{configuration}->{gorgone}->{gorgonecore}->{privkey}); + if ($rv == 0) { + $self->{logger}->writeLogInfo("[core] chmod private key file '$self->{config}->{configuration}->{gorgone}->{gorgonecore}->{privkey}': $!"); + } + $rv = chmod(0640, $self->{config}->{configuration}->{gorgone}->{gorgonecore}->{pubkey}); + if ($rv == 0) { + $self->{logger}->writeLogInfo("[core] chmod public key file '$self->{config}->{configuration}->{gorgone}->{gorgonecore}->{pubkey}': $!"); + } + ($code, $self->{server_privkey}) = gorgone::standard::library::loadprivkey( logger => $self->{logger}, privkey => $self->{config}->{configuration}->{gorgone}->{gorgonecore}->{privkey},