diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 2cb7a90..0d50134 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -4,15 +4,14 @@ import NIOSSL public extension Application { func configure() throws { - - http.server.configuration.port = 80 http.server.configuration.reuseAddress = true - if FileManager.default.fileExists(atPath: directory.workingDirectory + "/ssl/private.key") { + if let certPath = Environment.get("SSL_CERT_PATH"), let keyPath = Environment.get("SSL_KEY_PATH") { try http.server.configuration.tlsConfiguration = .makeServerConfiguration( - certificateChain: NIOSSLCertificate.fromPEMFile(directory.workingDirectory + "/ssl/certificate.crt").map { .certificate($0) }, - privateKey: .privateKey(.init(file: directory.workingDirectory + "/ssl/private.key", format: .pem)) + certificateChain: NIOSSLCertificate.fromPEMFile(certPath).map { .certificate($0) }, + privateKey: .privateKey(.init(file: keyPath, format: .pem)) ) + http.server.configuration.port = 443 } middleware.use(NotFoundMiddleware())