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

« back to all changes in this revision

Viewing changes to cgi-bin/browser-check.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
browser-check.py
 
5
(c) by Michael Stroeder <michael@stroeder.com>
 
6
 
 
7
CGI-BIN to check cryptographic abilities of a WWW
 
8
browser/server combination
 
9
The SSL data only works with the environment of ApacheSSL.
 
10
"""
 
11
 
 
12
Version='0.6.6'
 
13
 
 
14
########################################################################
 
15
# Some variables to configure the basic behaviour
 
16
########################################################################
 
17
 
 
18
# Do not list the environment vars listed here
 
19
hidden_envvars = [
 
20
  'DOCUMENT_ROOT','SCRIPT_NAME','SCRIPT_FILENAME','PATH',
 
21
  'SERVER_SOFTWARE','SSLEAY_VERSION','SERVER_SIGNATURE'
 
22
]
 
23
 
 
24
# Specifies a list of the acceptable symmetric key ciphers
 
25
# See also http://www.apache-ssl.org/ and the ApacheSSL
 
26
# run-time directives SSLBanCipher, SSLRequireCipher, SSLRequiredCiphers
 
27
sec_sslacceptedciphers = [
 
28
    'IDEA-CBC-SHA',
 
29
    'RC4-MD5',
 
30
    'RC4-SHA',
 
31
    'IDEA-CBC-MD5',
 
32
    'DES-CBC3-SHA',
 
33
    'DH-DSS-DES-CBC3-SHA',
 
34
    'DH-RSA-DES-CBC3-SHA',
 
35
    'EDH-DSS-DES-CBC3-SHA',
 
36
    'EDH-RSA-DES-CBC3-SHA',
 
37
    'ADH-RC4-MD5',
 
38
    'ADH-DES-CBC3-SHA',
 
39
    'FZA-RC4-SHA',
 
40
    'RC2-CBC-MD5',
 
41
    'DES-CBC3-MD5'
 
42
  ]
 
43
 
 
44
########################################################################
 
45
# There's nothing to configure below this line
 
46
########################################################################
 
47
 
 
48
import sys,os,string,time,re,urllib
 
49
 
 
50
import pycacnf,htmlbase,charset
 
51
 
 
52
###############################################################################
 
53
# Umgebungs-Variablen
 
54
###############################################################################
 
55
 
 
56
sys.stdin.close()
 
57
 
 
58
gmt=time.time()-3600*time.daylight+time.timezone
 
59
 
 
60
htmlbase.PrintHeader('Cryptographic Browser Check')
 
61
htmlbase.PrintHeading('Cryptographic Browser Check')
 
62
 
 
63
htmlbase.PrintHeading('SSL',2)
 
64
 
 
65
if os.environ.has_key('HTTPS'):
 
66
 
 
67
  htmlbase.PrintHeading('SSL symmetric cipher',3)
 
68
  print 'You connected with cipher <STRONG>%s</STRONG>, key size <STRONG>%s Bit</STRONG>, secret key size <STRONG>%s Bit</STRONG>.<P>' % (
 
69
          os.environ['SSL_CIPHER'],
 
70
          os.environ['HTTPS_KEYSIZE'],
 
71
          os.environ['HTTPS_SECRETKEYSIZE']
 
72
        )
 
73
 
 
74
  htmlbase.PrintHeading('Client Certificate',3)
 
75
  ssl_client_dn = os.environ.get('SSL_CLIENT_DN','')
 
76
  if ssl_client_dn:
 
77
    ssl_client_idn = os.environ.get('SSL_CLIENT_I_DN','')
 
78
    if not ssl_client_idn:
 
79
      ssl_client_idn = os.environ.get('SSL_CLIENT_IDN','')
 
80
    print 'Your client sent the following certificate:<TABLE BORDER=1><TR><TD>%s</TD><TD>%s</TD></TR></TABLE><P>' % (
 
81
           string.join(string.split(charset.t612html4(ssl_client_dn[1:]),'/'),'<BR>'),
 
82
           string.join(string.split(charset.t612html4(ssl_client_idn[1:]),'/'),'<BR>')
 
83
          )
 
84
  else:
 
85
    print 'Your client did not send a certificate or the server did not request a client certificate.'
 
86
 
 
87
else:
 
88
  print 'This was not a SSL connection at all.'
 
89
 
 
90
htmlbase.PrintHeading('Test Key Generation',2)
 
91
query_string=os.environ.get('QUERY_STRING','')
 
92
 
 
93
if query_string:
 
94
  spkac_rm=re.compile('^SPKAC=.*').match(query_string)
 
95
  if spkac_rm and spkac_rm.string==query_string:
 
96
    spkac_req=urllib.unquote_plus(query_string[6:])
 
97
    print 'Your client submitted the following SPKAC request (%d Bytes):<PRE>%s</PRE>' % (len(spkac_req),spkac_req)
 
98
  else:
 
99
    print 'The format of the submitted SPKAC request was wrong.'
 
100
else:
 
101
  print """
 
102
  <FORM ACTION="browser-check.py" METHOD="GET">
 
103
    Key length: <KEYGEN NAME="SPKAC" CHALLENGE="test">
 
104
    <INPUT TYPE="submit" VALUE="Generate Key Pair">
 
105
  </FORM>
 
106
  """
 
107
 
 
108
htmlbase.PrintHeading('Environment Variables')
 
109
print '<TABLE BORDER>'
 
110
env_keys=os.environ.keys()
 
111
 
 
112
hidden_envvars.append('QUERY_STRING')
 
113
for env in hidden_envvars:
 
114
  try:
 
115
    env_keys.remove(env)
 
116
  except ValueError:
 
117
    pass
 
118
env_keys.sort()
 
119
 
 
120
for env in env_keys:
 
121
  if env[0:4]!='SSL_':
 
122
    print '<TR><TD>%s</TD><TD>%s</TD></TR>' % (env,os.environ[env])
 
123
print '</TABLE>'
 
124
 
 
125
htmlbase.PrintFooter()
 
126
 
 
127
sys.exit(0)