This repository has been archived by the owner on Dec 31, 2024. It is now read-only.
forked from jhoblitt/puppet-port389
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial per instance ssl configuration
These params have been addded to the port389::instance define * ssl_server_port * ssl_cert * ssl_key * ssl_ca_certs
- Loading branch information
Joshua Hoblitt
committed
Jan 31, 2014
1 parent
dbb1c5e
commit b5f5e99
Showing
12 changed files
with
540 additions
and
2 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
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,8 @@ | ||
dn: cn=RSA,cn=encryption,cn=config | ||
changetype: add | ||
objectclass: top | ||
objectclass: nsEncryptionModule | ||
cn: RSA | ||
nsSSLPersonalitySSL: Server-Cert | ||
nsSSLToken: internal (software) | ||
nsSSLActivation: on |
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,18 @@ | ||
dn: cn=encryption,cn=config | ||
changetype: modify | ||
replace: nsSSL3 | ||
nsSSL3: on | ||
- | ||
replace: nsSSLClientAuth | ||
nsSSLClientAuth: allowed | ||
- | ||
replace: nsSSL3Ciphers | ||
nsSSL3Ciphers: -rsa_null_md5,+rsa_rc4_128_md5,+rsa_rc4_40_md5,+rsa_rc2_40_md5,+rsa_des_sha,+rsa_fips_des_sha,+rsa_3des_sha,+rsa_fips_3des_sha,+fortezza,+fortezza_rc4_128_sha,+fortezza_null,+tls_rsa_export1024_with_rc4_56_sha,+tls_rsa_export1024_with_des_cbc_sha,-rc4,-rc4export,-rc2,-rc2export,-des,-desede3 | ||
|
||
dn: cn=config | ||
changetype: modify | ||
add: nsslapd-security | ||
nsslapd-security: on | ||
- | ||
replace: nsslapd-ssl-check-hostname | ||
nsslapd-ssl-check-hostname: off |
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,62 @@ | ||
module Puppet::Parser::Functions | ||
newfunction(:port389_nssdb_add_cert, :doc => <<-EOS | ||
Iterates over a hash of cert nickname/path pairs (key/value) and creates | ||
nssdb::add_cert resources. | ||
*Example:* | ||
port389_nssdb_add_cert( | ||
'/etc/dirsrv/slapd-ldap1', | ||
{ | ||
'AlphaSSL CA' => '/tmp/alphassl_intermediate.pem', | ||
'GlobalSign Root CA' => '/tmp/globalsign_root.pem', | ||
} | ||
) | ||
Would effectively define these resources: | ||
nssdb::add_cert { 'AlphaSSL CA': | ||
certdir => '/etc/dirsrv/slapd-ldap1', | ||
nickname => 'AlphaSSL CA', | ||
cert => '/tmp/alphassl_intermediate.pem', | ||
} | ||
nssdb::add_cert { 'GlobalSign Root CA': | ||
certdir => '/etc/dirsrv/slapd-ldap1', | ||
nickname => 'GlobalSign Root CA', | ||
cert => '/tmp/globalsign_root.pem', | ||
} | ||
EOS | ||
) do |args| | ||
unless args.size == 2 | ||
raise(Puppet::ParseError, ":port389_nssdb_add_cert(): " + | ||
"Wrong number of arguments given #{args.size} for 2") | ||
end | ||
|
||
certdir = args[0] | ||
certs = args[1] | ||
|
||
unless certdir.is_a?(String) | ||
raise(Puppet::ParseError, ":port389_nssdb_add_cert(): " + | ||
"First argument must be a string") | ||
end | ||
|
||
unless certs.is_a?(Hash) | ||
raise(Puppet::ParseError, ":port389_nssdb_add_cert(): " + | ||
"Second argument must be a hash") | ||
end | ||
|
||
# we need to managle the resource name so multiple instances (and/or the | ||
# admin server) can reuse the same certs | ||
certs.each_pair do |nickname, cert| | ||
function_create_resources(['nssdb::add_cert', { | ||
"#{certdir}-#{nickname}" => { | ||
'certdir' => certdir, | ||
'nickname' => nickname, | ||
'cert' => cert, | ||
} | ||
}]) | ||
end | ||
end | ||
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
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,108 @@ | ||
# private type | ||
define port389::instance::ssl ( | ||
$root_dn, | ||
$root_dn_pwd, | ||
$server_port, | ||
$ssl_server_port, | ||
$ssl_cert, | ||
$ssl_key, | ||
$ssl_ca_certs, | ||
) { | ||
if $caller_module_name != $module_name { | ||
fail("Use of private type ${name} by ${caller_module_name}") | ||
} | ||
|
||
# we need the openldap client tools to configure the 389 server for SSL | ||
include openldap::client | ||
|
||
# based on SSL setup instructions from: | ||
# http://directory.fedoraproject.org/wiki/Howto:SSL#Starting_the_Server_with_SSL_enabled | ||
# and | ||
# https://access.redhat.com/site/documentation/en-US/Red_Hat_Directory_Server/9.0/html/Administration_Guide/Managing_SSL.html | ||
|
||
# how to change default ssl port | ||
# https://access.redhat.com/site/documentation/en-US/Red_Hat_Directory_Server/9.0/html/Administration_Guide/Configuring_LDAP_Parameters-Changing_DS_Port_Numbers.html#changing-ssl-ports | ||
|
||
ensure_resource('file', 'ssl_enable.ldif', { | ||
ensure => file, | ||
path => "${::port389::setup_dir}/ssl_enable.ldif", | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0640', | ||
source => "puppet:///modules/${module_name}/ssl_enable.ldif", | ||
backup => false, | ||
}) | ||
|
||
ensure_resource('file', 'addRSA.ldif', { | ||
ensure => file, | ||
path => "${::port389::setup_dir}/addRSA.ldif", | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0640', | ||
source => "puppet:///modules/${module_name}/addRSA.ldif", | ||
backup => false, | ||
}) | ||
|
||
file { "set_secureport_${name}.ldif": | ||
ensure => file, | ||
path => "${::port389::setup_dir}/set_secureport_${name}.ldif", | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0640', | ||
content => template("${module_name}/set_secureport.ldif.erb"), | ||
backup => false, | ||
} | ||
|
||
$ldap_connect = "-x -H \"ldap://localhost:${server_port}\" -D \"${root_dn}\" -w \"${root_dn_pwd}\"" | ||
|
||
exec { "ssl_enable.ldif-${name}": | ||
path => ['/bin', '/usr/bin'], | ||
command => "ldapmodify ${ldap_connect} -f ${::port389::setup_dir}/ssl_enable.ldif", | ||
unless => "ldapsearch ${ldap_connect} -b cn=encryption,cn=config \"nsSSL3=on\" nsSSL3 | grep \"nsSSL3: on\"", | ||
logoutput => true, | ||
require => [Class['openldap::client'], File['ssl_enable.ldif']], | ||
} -> | ||
exec { "addRSA.ldif-${name}": | ||
path => ['/bin', '/usr/bin'], | ||
command => "ldapmodify ${ldap_connect} -f ${::port389::setup_dir}/addRSA.ldif", | ||
unless => "ldapsearch ${ldap_connect} -b cn=RSA,cn=encryption,cn=config \"nsSSLActivation=on\" nsSSLActivation | grep \"nsSSLActivation: on\"", | ||
logoutput => true, | ||
require => [Class['openldap::client'], File['addRSA.ldif']], | ||
} -> | ||
exec { "set_secureport_${name}.ldif": | ||
path => ['/bin', '/usr/bin'], | ||
command => "ldapmodify ${ldap_connect} -f ${::port389::setup_dir}/set_secureport_${name}.ldif", | ||
unless => "ldapsearch ${ldap_connect} -b cn=config \"nsslapd-secureport=${ssl_server_port}\" nsslapd-secureport | grep \"nsslapd-secureport: ${ssl_server_port}\"", | ||
logoutput => true, | ||
require => [Class['openldap::client'], File["set_secureport_${name}.ldif"]], | ||
} | ||
|
||
$certdir = "/etc/dirsrv/slapd-${name}" | ||
|
||
file { "pin.txt-${name}": | ||
ensure => file, | ||
path => "${certdir}/pin.txt", | ||
owner => $::port389::user, | ||
group => $::port389::group, | ||
mode => '0400', | ||
content => "Internal (Software) Token:${root_dn_pwd}", | ||
} | ||
|
||
nssdb::create { $certdir: | ||
owner_id => $::port389::user, | ||
group_id => $::port389::group, | ||
mode => '0660', | ||
password => $root_dn_pwd, | ||
manage_certdir => false, | ||
} | ||
|
||
nssdb::add_cert_and_key { $certdir: | ||
nickname => 'Server-Cert', | ||
cert => $ssl_cert, | ||
key => $ssl_key, | ||
} | ||
|
||
if size(keys($ssl_ca_certs)) > 0 { | ||
port389_nssdb_add_cert("/etc/dirsrv/slapd-${name}", $ssl_ca_certs) | ||
} | ||
} |
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
Oops, something went wrong.