This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
portusctl: disable automatic generation of certificates
Introduce two new flags regarding SSL certificates: * --ssl-gen-self-signed-certs * --ssl-certs-dir <dir> The former, as the name suggests, creates self-signed certificates. The latter uses certificates located in the specified directory. From there, it will copy the certificates to the apache directory and continue the process as before. Should either one of the certificates be missing, it will fail with a meaningful message. If neither flag is specified, it assumes the certificates are already located in `/etc/apache2/ssl.{key,crt}/`. As before, should either one of the certificates be missing, it will fail with a meaningful message. These two flags are mutually exclusive. Signed-off-by: Thomas Hipp <[email protected]>
- Loading branch information
Thomas Hipp
committed
May 9, 2016
1 parent
17be80f
commit d34714f
Showing
4 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
def check_setup_flags(options) | ||
if options["ssl-gen-self-signed-certs"] && \ | ||
!options["ssl-certs-dir"].chomp.empty? | ||
warn "cannot use both options --ssl-gen-self-signed-certs and " \ | ||
"--ssl-certs-dir at the same time" | ||
exit 1 | ||
end | ||
|
||
return unless options["ldap-enable"] && \ | ||
(options["ldap-hostname"].nil? || options["ldap-hostname"].empty?) | ||
|
||
warn "LDAP support is enabled but you didn't specify a value for ldap-hostname" | ||
exit 1 | ||
end | ||
|
||
def ensure_root | ||
return if Process.uid == 0 | ||
|
||
warn "Must run as root user" | ||
exit 1 | ||
end | ||
|
||
def handle_own_certs(path) | ||
puts "Using keys from #{path}" | ||
key_file = File.join(path, "#{HOSTNAME}-ca.key") | ||
crt_file = File.join(path, "#{HOSTNAME}-ca.crt") | ||
|
||
missing_file(key_file, path) unless File.exist?(key_file) | ||
FileUtils.cp(key_file, "/etc/apache2/ssl.key") | ||
|
||
missing_file(crt_file, path) unless File.exist?(crt_file) | ||
FileUtils.cp(crt_file, "/etc/apache2/ssl.crt") | ||
end | ||
|
||
def missing_file(filename, path = "") | ||
if path.empty? | ||
warn "missing file #{filename}.\n" \ | ||
"Use --ssl-gen-self-signed-certs to generate new certificates, or " \ | ||
"--ssl-certs-dir <path> to specify a directory containing certificates." | ||
else | ||
warn "cannot find file #{File.basename filename} inside of #{path}." | ||
end | ||
exit 1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters