~ubuntu-branches/ubuntu/raring/pyca/raring

« back to all changes in this revision

Viewing changes to cgi-bin/ca-index.py

  • Committer: Bazaar Package Importer
  • Author(s): Lars Bahner
  • Date: 2003-12-02 19:39:35 UTC
  • Revision ID: james.westby@ubuntu.com-20031202193935-fzzt289mntvy6a8q
Tags: upstream-20031118
ImportĀ upstreamĀ versionĀ 20031118

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
"""
 
4
ca-index.py
 
5
(c) by Michael Stroeder <michael@stroeder.com>
 
6
 
 
7
This CGI-BIN program shows a pretty index of the CA definitions in
 
8
OpenSSL's config file (e.g. named openssl.cnf)
 
9
"""
 
10
 
 
11
__version__ = '0.6.6'
 
12
 
 
13
import os, sys, types, string, pycacnf, openssl, htmlbase
 
14
 
 
15
from pycacnf import opensslcnf, pyca_section
 
16
 
 
17
nsGetCertUrl = pyca_section.get('nsGetCertUrl','')
 
18
nsViewCertUrl = pyca_section.get('nsViewCertUrl','')
 
19
nsEnrollUrl  = pyca_section.get('nsEnrollUrl','')
 
20
 
 
21
ca_names = opensslcnf.sectionkeys.get('ca',[])
 
22
 
 
23
if not ca_names:
 
24
  htmlbase.PrintErrorMsg('No certificate authorities found.')
 
25
  sys.exit(0)
 
26
 
 
27
htmlbase.PrintHeader('Overview of certificate authorities')
 
28
htmlbase.PrintHeading('Overview of certificate authorities')
 
29
print """<TABLE BORDER WIDTH=100%>
 
30
<TR>
 
31
  <TH>CA name</TH>
 
32
  <TH COLSPAN=2>CA certificate</TH>
 
33
  <TH COLSPAN=2>CRL</TH>
 
34
  <TH>certificate<BR>types</TH>
 
35
  <TH>Comment</TH>
 
36
  <TH>View policy</TH>
 
37
</TR>
 
38
"""
 
39
 
 
40
for ca_name in ca_names:
 
41
  ca = opensslcnf.getcadata(ca_name)
 
42
  if nsEnrollUrl and ca.isclientcert():
 
43
    nsCertTypeStr = '<A HREF="%s%s/%s">%s</A>' % (ca.nsBaseUrl,nsEnrollUrl,ca_name,ca.nsCertTypeStr)
 
44
  else:
 
45
    if ca.nsCertTypeStr:
 
46
      nsCertTypeStr = '%s' % (ca.nsCertTypeStr)
 
47
    else:
 
48
      nsCertTypeStr = '&nbsp;'
 
49
  if ca.nsCaRevocationUrl:
 
50
    nsCaRevocationUrl='<A HREF="%s%s">load</A>' % (ca.nsBaseUrl,ca.nsCaRevocationUrl)
 
51
    nsViewRevocationUrl='<A HREF="%s%s/%s/crl">view</A>' % (ca.nsBaseUrl,nsViewCertUrl,ca_name)
 
52
  else:
 
53
    nsCaRevocationUrl   = '&nbsp;'
 
54
    nsViewRevocationUrl = '&nbsp;'
 
55
  if ca.nsCaPolicyUrl:
 
56
    nsCaPolicyUrl='<A HREF="%s%s">Policy of %s</A>' % (ca.nsBaseUrl,ca.nsCaPolicyUrl,ca_name)
 
57
  else:
 
58
    nsCaPolicyUrl='-'
 
59
 
 
60
  print """
 
61
<TR>
 
62
  <TD>%s</TD>
 
63
  <TD><A HREF="%s%s/%s/ca.crt">load</A></TD>
 
64
  <TD><A HREF="%s%s/%s/ca">view</A></TD>
 
65
  <TD>%s</TD>
 
66
  <TD>%s</TD>
 
67
  <TD>%s</TD>
 
68
  <TD>%s</TD>
 
69
  <TD>%s</TD>
 
70
<TR>
 
71
""" % (
 
72
  ca_name,
 
73
  ca.nsBaseUrl,
 
74
  nsGetCertUrl,
 
75
  ca_name,
 
76
  ca.nsBaseUrl,
 
77
  nsViewCertUrl,
 
78
  ca_name,
 
79
  nsCaRevocationUrl,
 
80
  nsViewRevocationUrl,
 
81
  nsCertTypeStr,
 
82
  ca.nsComment,
 
83
  nsCaPolicyUrl
 
84
)
 
85
 
 
86
print '</TABLE><P>'
 
87
 
 
88
print '<A HREF="cert-query.py">Search for issued certificates.</A>'
 
89
 
 
90
htmlbase.PrintFooter()
 
91
sys.exit(0)