2
# Alexander Bokovoy <abokovoy@redhat.com>
4
# Copyright (C) 2012 Red Hat
5
# see file 'COPYING' for use and warranty information
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
from ipaserver.install.plugins import MIDDLE
21
from ipaserver.install.plugins.baseupdate import PostUpdate
22
from ipaserver.install.dsinstance import realm_to_serverid, config_dirname
23
from ipaserver.install import certs
24
from ipalib import api
25
from ipapython.dn import DN
28
class update_upload_cacrt(PostUpdate):
30
Upload public CA certificate to LDAP
34
def execute(self, **options):
35
ldap = self.obj.backend
36
(cdn, ipa_config) = ldap.get_ipa_config()
37
subject_base = ipa_config.get('ipacertificatesubjectbase', [None])[0]
38
dirname = config_dirname(realm_to_serverid(api.env.realm))
39
certdb = certs.CertDB(api.env.realm, nssdir=dirname, subject_base=subject_base)
41
dercert = certdb.get_cert_from_db(certdb.cacert_name, pem=False)
44
dn = DN(('cn', 'CACert'), ('cn', 'ipa'), ('cn','etc'), api.env.basedn)
46
cacrt_entry = ['objectclass:nsContainer',
49
'cACertificate;binary:%s' % dercert,
51
updates[dn] = {'dn': dn, 'default': cacrt_entry}
53
return (False, True, [updates])
55
api.register(update_upload_cacrt)