New test.
[mono.git] / mcs / class / System.Web / Test / standalone / security / clientcert.aspx
1 <!-- you need an updated XSP to handle this correctly -->
2 <%@ Page language="c#" %>
3 <html>
4         <head>
5                 <script runat="server">
6                 string GetValue (byte[] data)
7                 {
8                         if ((data == null) || (data.Length == 0))
9                                 return "(empty)";
10                         return BitConverter.ToString (data);
11                 }
12
13                 void Page_Load (object sender, EventArgs e)
14                 {
15                         System.Text.StringBuilder sb = new System.Text.StringBuilder ();
16                         HttpClientCertificate hcc = Request.ClientCertificate;
17                         if (hcc.IsPresent) {
18                                 sb.Append ("Client certificate retrieved.");
19                                 sb.AppendFormat ("\n<br>BinaryIssuer: {0}", GetValue (hcc.BinaryIssuer));
20                                 sb.AppendFormat ("\n<br>CertEncoding: {0}", hcc.CertEncoding);
21                                 sb.AppendFormat ("\n<br>Certificate: {0}", GetValue (hcc.Certificate));
22                                 sb.AppendFormat ("\n<br>Cookie: {0}", hcc.Cookie);
23                                 sb.AppendFormat ("\n<br>Flags: {0}", hcc.Flags);
24                                 sb.AppendFormat ("\n<br>IsValid: {0}", hcc.IsValid);
25                                 sb.AppendFormat ("\n<br>KeySize: {0}", hcc.KeySize);
26                                 sb.AppendFormat ("\n<br>PublicKey: {0}", GetValue (hcc.PublicKey));
27                                 sb.AppendFormat ("\n<br>SecretKeySize: {0}", hcc.SecretKeySize);
28                                 sb.AppendFormat ("\n<br>SerialNumber: {0}", hcc.SerialNumber);
29                                 sb.AppendFormat ("\n<br>ServerIssuer: {0}", hcc.ServerIssuer);
30                                 sb.AppendFormat ("\n<br>ServerSubject: {0}", hcc.ServerSubject);
31                                 sb.AppendFormat ("\n<br>Subject: {0}", hcc.Subject);
32                                 sb.AppendFormat ("\n<br>ValidFrom: {0}", hcc.ValidFrom);
33                                 sb.AppendFormat ("\n<br>ValidUntil: {0}", hcc.ValidUntil);
34
35                                 System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate (hcc.Certificate);
36                                 sb.AppendFormat ("\n<br>X509Certificate: {0}", cert.ToString (true).Replace ("\n", "\n<br>"));
37                         } else {
38                                 sb.Append ("No client certificate");
39                                 if (Request.IsSecureConnection) {
40                                         sb.Append (" was sent during negotiation.");
41                                 } else {
42                                         sb.Append (", and this can't work unless you use HTTPS!");
43                                 }
44                         }
45                         info.Text = sb.ToString ();
46                 }
47                 </script>
48         </head>
49         <body>
50                 <form runat="server">
51                         <asp:Label id="info" runat="server" />
52                 </form>
53         </body>
54 </html>