summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin/Fingerprint.py
blob: bf50f0aaa97a3219f7c52d04dc15a9adb62ce283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'''Fingerprint mode for bcfg2-admin'''

import Bcfg2.tlslite.api
import Bcfg2.Server.Admin

class Fingerprint(Bcfg2.Server.Admin.Mode):
    '''Produce server key fingerprint'''
    __shorthelp__ = 'bcfg2-admin fingerprint'
    __longhelp__ = __shorthelp__ + '\n\tPrint the server certificate fingerprint'
    def __call__(self, args):
        Bcfg2.Server.Admin.Mode.__call__(self, args)
        print self.getFingerprint()

    def getFingerprint(self):
        '''calculate key fingerprint'''
        keypath = self.cfp.get('communication', 'key')
        x509 = Bcfg2.tlslite.api.X509()
        x509.parse(open(keypath).read())
        return x509.getFingerprint()