Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Authors: # Jason Gerard DeRose <jderose@redhat.com> # Rob Crittenden <rcritten@redhat.com> # Pavel Zuna <pzuna@redhat.com> # # Copyright (C) 2008 Red Hat # see file 'COPYING' for use and warranty information # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
Services
A IPA service represents a service that runs on a host. The IPA service record can store a Kerberos principal, an SSL certificate, or both.
An IPA service can be managed directly from a machine, provided that machine has been given the correct permission. This is true even for machines other than the one the service is associated with. For example, requesting an SSL certificate using the host service principal credentials of the host. To manage a service using host credentials you need to kinit as the host:
# kinit -kt /etc/krb5.keytab host/ipa.example.com@EXAMPLE.COM
Adding an IPA service allows the associated service to request an SSL certificate or keytab, but this is performed as a separate step; they are not produced as a result of adding the service.
Only the public aspect of a certificate is stored in a service record; the private key is not stored.
EXAMPLES:
Add a new IPA service: ipa service-add HTTP/web.example.com
Allow a host to manage an IPA service certificate: ipa service-add-host --hosts=web.example.com HTTP/web.example.com ipa role-add-member --hosts=web.example.com certadmin
Override a default list of supported PAC types for the service: ipa service-mod HTTP/web.example.com --pac-type=MS-PAC
Delete an IPA service: ipa service-del HTTP/web.example.com
Find all IPA services associated with a host: ipa service-find web.example.com
Find all HTTP services: ipa service-find HTTP
Disable the service Kerberos key and SSL certificate: ipa service-disable HTTP/web.example.com
Request a certificate for an IPA service: ipa cert-request --principal=HTTP/web.example.com example.csr
Generate and retrieve a keytab for an IPA service: ipa-getkeytab -s ipa.example.com -p HTTP/web.example.com -k /etc/httpd/httpd.keytab
""")
Flag('has_keytab', label=_('Keytab'), ), Str('managedby_host', label='Managed by', ), Str('subject', label=_('Subject'), ), Str('serial_number', label=_('Serial Number'), ), Str('serial_number_hex', label=_('Serial Number (hex)'), ), Str('issuer', label=_('Issuer'), ), Str('valid_not_before', label=_('Not Before'), ), Str('valid_not_after', label=_('Not After'), ), Str('md5_fingerprint', label=_('Fingerprint (MD5)'), ), Str('sha1_fingerprint', label=_('Fingerprint (SHA1)'), ), Str('revocation_reason?', label=_('Revocation reason'), ) )
# Break down the principal into its component parts, which may or # may not include the realm.
raise errors.MalformedServicePrincipal(reason=_('blank service')) raise errors.MalformedServicePrincipal( reason=_('unable to determine realm'))
# At some point we'll support multiple realms else:
# Note that realm may be None.
# The principal is already validated when it gets here # Put the principal back together again
""" For now just verify that it is properly base64-encoded. """ except Exception, e: raise errors.Base64DecodeError(reason=str(e)) else: # We'll assume this is DER data
""" Set individual attributes from some values from a certificate.
entry_attrs is a dict of an entry
returns nothing """ else: cert = entry_attrs['usercertificate']
""" Raise an error if the host of this prinicipal is an IPA master and one of the principals required for proper execution. """
""" Service object. """ 'krbprincipal', 'krbprincipalaux', 'krbticketpolicyaux', 'ipaobject', 'ipaservice', 'pkiuser' ] 'ipakrbauthzdata',] 'managedby': ['host'], } 'managedby': ('Managed by', 'man_by_', 'not_man_by_'), }
Str('krbprincipalname', validate_principal, cli_name='principal', label=_('Principal'), doc=_('Service principal'), primary_key=True, normalizer=lambda value: normalize_principal(value), ), Bytes('usercertificate?', validate_certificate, cli_name='certificate', label=_('Certificate'), doc=_('Base-64 encoded server certificate'), flags=['no_search',], ), StrEnum('ipakrbauthzdata*', cli_name='pac_type', label=_('PAC type'), doc=_("Override default list of supported PAC types." " Use 'NONE' to disable PAC support for this service"), values=(u'MS-PAC', u'PAD', u'NONE'), csv=True, ), )
new_value = set([new_value]) else:
error=_('NONE value cannot be combined with other PAC types'))
Flag('force', label=_('Force'), doc=_('force principal name even if not in DNS'), ), )
except errors.NotFound: raise errors.NotFound( reason=_("The host '%s' does not exist to add a service to.") % hostname)
dercert = x509.normalize_certificate(cert) x509.verify_cert_subject(ldap, hostname, dercert) entry_attrs['usercertificate'] = dercert
# We know the host exists if we've gotten this far but we # really want to discourage creating services for hosts that # don't exist in DNS. util.validate_host_dns(self.log, hostname)
# Enforce ipaKrbPrincipalAlias to aid case-insensitive searches # as krbPrincipalName/krbCanonicalName are case-sensitive in Kerberos # schema
# Objectclass ipakrbprincipal providing ipakrbprincipalalias is not in # in a list of default objectclasses, add it manually
# In the case of services we don't want IPA master services to be # deleted. This is a limited few though. If the user has their own # custom services allow them to manage them. except errors.NotImplementedError: # some CA's might not implement revoke pass except errors.NotImplementedError: # some CA's might not implement revoke pass except NSPRError, nsprerr: if nsprerr.errno == -8183: # If we can't decode the cert them proceed with # removing the service. self.log.info("Problem decoding certificate %s" % nsprerr.args[1]) else: raise nsprerr
dn, ['usercertificate']) # FIXME: what to do here? do we revoke the old cert? fmt = 'entry already has a certificate, serial number: %s' % ( x509.get_serial_number(entry_attrs_old['usercertificate'][0], x509.DER) ) raise errors.GenericError(format=fmt) else:
'%(count)d service matched', '%(count)d services matched', 0 )
# lisp style! '(!(objectClass=posixAccount))' \ '(!(|(krbprincipalname=kadmin/*)' \ '(krbprincipalname=K/M@*)' \ '(krbprincipalname=krbtgt/*))' \ ')' \ ')' ldap.combine_filters((custom_filter, filter), rules=ldap.MATCH_ALL), base_dn, scope )
return truncated
Str('out?', doc=_('file to store certificate in'), ), )
util.check_writable_file(options['out']) result = super(service_show, self).forward(*keys, **options) if 'usercertificate' in result['result']: x509.write_certificate(result['result']['usercertificate'][0], options['out']) result['summary'] = _('Certificate stored in file \'%(file)s\'') % dict(file=options['out']) return result else: raise errors.NoCertificateError(entry=keys[-1]) else:
# See if we do any work at all here and if not raise an exception
cert = x509.normalize_certificate(entry_attrs.get('usercertificate')[0]) try: serial = unicode(x509.get_serial_number(cert, x509.DER)) try: result = api.Command['cert_show'](unicode(serial))['result'] if 'revocation_reason' not in result: try: api.Command['cert_revoke'](unicode(serial), revocation_reason=4) except errors.NotImplementedError: # some CA's might not implement revoke pass except errors.NotImplementedError: # some CA's might not implement revoke pass except NSPRError, nsprerr: if nsprerr.errno == -8183: # If we can't decode the cert them proceed with # disabling the service self.log.info("Problem decoding certificate %s" % nsprerr.args[1]) else: raise nsprerr
# Remove the usercertificate altogether ldap.update_entry(dn, {'usercertificate': None}) done_work = True
raise errors.AlreadyInactive()
result=True, value=keys[0], )
|