Skip to content

Commit 8e683de

Browse files
author
Thanos Ploumis
committed
Unify certificates
1 parent 5d6f355 commit 8e683de

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

core/src/main/groovy/noe/server/Httpd.groovy

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ abstract class Httpd extends ServerAbstract {
5050
String cachePath // directory for mod_cache caching
5151
File postInstallErrFile
5252
File postInstallOutFile
53-
File sslCertDir
53+
File sslCertsDir //Path to directory holding ssl certificates
54+
File sslPrivateDir //Path to directory holding ssl keys
55+
File sslKeystoresDir //Path to directory holding ssl keystores
5456

5557
Httpd(String basedir, version) {
5658
super(basedir, version)
@@ -67,11 +69,10 @@ abstract class Httpd extends ServerAbstract {
6769
this.cachePath = this.basedir + platform.sep + 'cache'
6870
postInstallErrFile = new File(getHttpdServerRootFull(), 'httpdPostInstallErr.log')
6971
postInstallOutFile = new File(getHttpdServerRootFull(), 'httpdPostInstallOut.log')
70-
String sslStringDir = PathHelper.join(platform.tmpDir, "ssl", "self_signed")
71-
this.sslCertDir = new File(sslStringDir)
72-
this.sslCertificate = new File(sslCertDir, "server.crt").absolutePath
73-
this.sslKey = new File(sslCertDir, "server.key").absolutePath
74-
this.keystorePath = new File(sslCertDir, "server.jks").absolutePath
72+
String sslStringDir = PathHelper.join(platform.tmpDir, "ssl", "proper", "generated", "ca", "intermediate")
73+
this.sslCertificate = new File(sslStringDir, "localhost.server.cert.pem").absolutePath
74+
this.sslKey = new File(sslStringDir, "localhost.server.key.pem").absolutePath
75+
this.keystorePath = new File(sslStringDir,"localhost.server.keystore.jks").absolutePath
7576
}
7677

7778
static ServerAbstract getInstance(String basedir, version, String httpdDir = '', NoeContext context = NoeContext.forCurrentContext()) {

core/src/main/groovy/noe/server/ServerAbstract.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ abstract class ServerAbstract implements IApp {
9898
this.serverRoot = basedir
9999
this.host = (host) ?: DefaultProperties.HOST
100100
this.ignoreShutdownPort = true
101-
this.sslCertificate = getDeplSrcPath() + "${platform.sep}ssl${platform.sep}self_signed${platform.sep}server.crt"
102-
this.sslKey = getDeplSrcPath() + "${platform.sep}ssl${platform.sep}self_signed${platform.sep}server.key"
103-
this.keystorePath = getDeplSrcPath() + "${platform.sep}ssl${platform.sep}self_signed${platform.sep}server.jks"
104-
this.truststorePassword = 'changeit'
105-
this.sslKeystorePassword = 'changeit'
101+
this.sslCertificate = getDeplSrcPath() + "${platform.sep}ssl${platform.sep}proper${platform.sep}generated${platform.sep}ca${platform.sep}intermediate${platform.sep}localhost.server.cert.pem"
102+
this.sslKey = getDeplSrcPath() + "${platform.sep}ssl${platform.sep}proper${platform.sep}generated${platform.sep}ca${platform.sep}intermediate${platform.sep}localhost.server.key.pem"
103+
this.keystorePath = getDeplSrcPath() + "${platform.sep}ssl${platform.sep}proper${platform.sep}generated${platform.sep}ca${platform.sep}intermediate${platform.sep}localhost.server.keystore.jks"
104+
this.truststorePassword = 'testpass'
105+
this.sslKeystorePassword = 'testpass'
106106
this.pid = null
107107
setRunAs(loadRunAs())
108108
this.processCode = String.valueOf(Math.abs(this.hashCode()))

core/src/main/groovy/noe/server/Tomcat.groovy

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Tomcat extends ServerAbstract implements WorkerServer {
4242
def rootBasedir
4343
File postInstallErrFile
4444
File postInstallOutFile
45-
File sslCertDir //Path to directory holding ssl certificates
4645

4746
Tomcat(String basedir, version) {
4847
super(basedir, version)
@@ -62,12 +61,10 @@ class Tomcat extends ServerAbstract implements WorkerServer {
6261
this.cfgHost = (cfgHost) ?: ''
6362
postInstallErrFile = new File(basedir, 'tomcatPostInstallErr.log')
6463
postInstallOutFile = new File(basedir, 'tomcatPostInstallOut.log')
65-
String sslStringDir = PathHelper.join(platform.tmpDir, "ssl", "self_signed")
66-
this.sslCertDir = new File(sslStringDir)
67-
this.sslCertificate = new File(sslCertDir, "server.crt").absolutePath
68-
this.sslKey = new File(sslCertDir, "server.key").absolutePath
69-
this.keystorePath = new File(sslCertDir, "server.jks").absolutePath
70-
64+
String sslStringDir = PathHelper.join(platform.tmpDir, "ssl", "proper", "generated", "ca", "intermediate")
65+
this.sslCertificate = new File(sslStringDir, "localhost.server.cert.pem").absolutePath
66+
this.sslKey = new File(sslStringDir, "localhost.server.key.pem").absolutePath
67+
this.keystorePath = new File(sslStringDir,"localhost.server.keystore.jks").absolutePath
7168
}
7269

7370
static ServerAbstract getInstance(String basedir, version, String tomcatDir = "", NoeContext context = NoeContext.forCurrentContext()) {

core/src/main/groovy/noe/tomcat/configure/SecureHttpConnectorTomcat.groovy

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package noe.tomcat.configure
22

3+
import noe.common.utils.PathHelper
34
import noe.common.utils.Platform
45

56
/**
@@ -52,23 +53,22 @@ public class SecureHttpConnectorTomcat extends ConnectorTomcatAbstract<SecureHtt
5253
}
5354

5455
/**
55-
* Configure secure http connector to expect certificates in ${SYSTEM_TEMP}/ssl/self_signed directory
56+
* Configure secure http connector to expect certificates in ${SYSTEM_TEMP}/ssl/proper/generated/ca/intermediate directory
5657
* Expected names:
5758
* <ul>
58-
* <li>certificate = server.crt</li>
59-
* <li>key file = server.key</li>
60-
* <li>keystore = server.jks</li>
59+
* <li>certificate = localhost.server.cert.pem</li>
60+
* <li>key file = localhost.server.key.pem</li>
61+
* <li>keystore = localhost.server.keystore.jks</li>
6162
* <li></li>
6263
* </ul>
6364
* Password for keystore, trustore and SSL sets to "changeit" (without apostrophes).
6465
*/
6566
SecureHttpConnectorTomcat setDefaultCertificatesConfiguration() {
66-
String sslRoot = new File(new Platform().getTmpDir(), "ssl").getCanonicalPath()
67-
String sslStringDir = new File(sslRoot, "self_signed").getCanonicalPath()
68-
String sslCertificate = new File(sslStringDir, "server.crt").getCanonicalPath()
69-
String sslCertificateKey = new File(sslStringDir, "server.key").getCanonicalPath()
70-
String keystoreFilePath = new File(sslStringDir, "server.jks").getCanonicalPath()
71-
String password = "changeit"
67+
String sslStringDir = PathHelper.join(new Platform().getTmpDir(), "ssl", "proper", "generated", "ca", "intermediate").getCanonicalPath()
68+
String sslCertificate = new File(sslStringDir, "localhost.server.cert.pem").getCanonicalPath()
69+
String sslCertificateKey = new File(sslStringDir, "localhost.server.key.pem").getCanonicalPath()
70+
String keystoreFilePath = new File(sslStringDir, "localhost.server.keystore.jks").getCanonicalPath()
71+
String password = "testpass"
7272

7373
setSslCertificateFile(sslCertificate)
7474
setSslCertificateKeyFile(sslCertificateKey)

core/src/main/groovy/noe/workspace/WorkspaceAbstract.groovy

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,21 @@ abstract class WorkspaceAbstract implements IWorkspace {
123123
* Copies self-signed, pre-generated certificates from noe core to ${tmpdir}/ssl/self_signed directory.
124124
*
125125
*/
126+
126127
void copyCertificates() {
127-
List<String> certificates = ["server.crt", "server.jks", "server.key", "server.p12"]
128-
String sslStringDir = PathHelper.join(platform.tmpDir, "ssl", "self_signed")
128+
List<String> certificates = ["localhost.server.cert.pem", "localhost.server.key.pem", "localhost.server.keystore.jks"]
129+
List<String> certificatesPaths = ["ssl/proper/generated/ca/intermediate/certs/", "ssl/proper/generated/ca/intermediate/private/", "ssl/proper/generated/ca/intermediate/keystores/"]
130+
String sslStringDir = PathHelper.join(platform.tmpDir, "ssl", "proper", "generated", "ca", "intermediate")
129131
File sslDir = new File(sslStringDir)
130-
String resourcesPath = "ssl/self_signed/" //resources jar path is always separated by /
131132

132133
if (!sslDir.exists()) {
133134
JBFile.mkdir(sslDir)
134135
}
135136

136137
JBFile.makeAccessible(sslDir)
137138

138-
for (String certName : certificates) {
139-
File certFile = Library.retrieveResourceAsFile("${resourcesPath}${certName}")
139+
for (int i = 0; i < 3; i++) {
140+
File certFile = Library.retrieveResourceAsFile("${certificatesPaths[i]}${certificates[i]}")
140141
JBFile.move(certFile, sslDir)
141142
}
142143
}

0 commit comments

Comments
 (0)