Browse Source

HPCC-19328 Self Signed Certificate generation at installation

Signed-off-by: Michael Gardner <michael.garder@lexisnexisrisk.com>

HPCC-19328 Changes for review

Signed-off-by: Michael Gardner <michael.gardner@lexisnexisrisk.com>
Michael Gardner 7 years ago
parent
commit
cbb8dfcf68

+ 15 - 0
initfiles/bash/etc/init.d/install-init.in

@@ -235,6 +235,21 @@ else
     log_success_msg
 fi
 
+if [ ! -d ${homePath}/certificate ]; then
+    mkdir -p ${homePath}/certificate
+fi
+
+if [ ! -e ${homePath}/certificate/certificate.pem ]; then
+    openssl req -newkey rsa:2048 -keyout ${homePath}/certificate/key.pem -x509 \
+        -days 365 -out ${homePath}/certificate/certificate.pem -passin \
+        pass:hpccsystems-platform -passout pass:hpccsystems-platform -batch 1>/dev/null 2>&1
+    printf "Self Signed Certificate installed for user %-12s ..." "$user"
+    log_success_msg
+else
+    printf "Self Signed Certificate already installed for user %-12s ..." "$user"
+    log_success_msg
+fi
+
 # Added code to change environment.conf file user home directory location for key generation
 if [ "$homeBase" != "$home" ]; then
     sed -e "s;^[[:space:]]*home[[:space:]]*=.*$;home=$homeBase;" ${CONFIG_DIR}/${ENV_CONF_FILE} > temp.conf

+ 4 - 4
initfiles/componentfiles/configxml/esp.xsd.in

@@ -457,21 +457,21 @@
                                 </xs:appinfo>
                             </xs:annotation>
                         </xs:attribute>
-                        <xs:attribute name="certificateFileName" type="xs:string" use="optional" default="certificate.cer">
+                        <xs:attribute name="certificateFileName" type="xs:string" use="optional" default="@HOME_DIR@/@RUNTIME_USER@/certificate/certificate.pem">
                             <xs:annotation>
                                 <xs:appinfo>
                                     <tooltip>Name of destination file in which the certificate will be written.</tooltip>
                                 </xs:appinfo>
                             </xs:annotation>
                         </xs:attribute>
-                        <xs:attribute name="privateKeyFileName" type="xs:string" use="optional" default="privatekey.cer">
+                        <xs:attribute name="privateKeyFileName" type="xs:string" use="optional" default="@HOME_DIR@/@RUNTIME_USER@/certificate/key.pem">
                             <xs:annotation>
                                 <xs:appinfo>
                                     <tooltip>Name of destination file in which the private key will be written.</tooltip>
                                 </xs:appinfo>
                             </xs:annotation>
                         </xs:attribute>
-                        <xs:attribute name="passphrase" type="xs:string" use="optional">
+                        <xs:attribute name="passphrase" type="xs:string" use="optional" default="hpccsystems-platform">
                             <xs:annotation>
                                 <xs:appinfo>
                                     <viewType>password</viewType>
@@ -500,7 +500,7 @@
                                 </xs:appinfo>
                             </xs:annotation>
                         </xs:attribute>
-                        <xs:attribute name="CA_Certificates_Path" type="xs:string" use="optional" default="ca.pem">
+                        <xs:attribute name="CA_Certificates_Path" type="xs:string" use="optional" default="@HOME_DIR@/@RUNTIME_USER@/certificate">
                             <xs:annotation>
                                 <xs:appinfo>
                                     <tooltip>path to the file that contains CA certificates.</tooltip>