**** Merged from MCS ****
[mono-project.git] / mcs / class / Microsoft.Web.Services / Test / Microsoft.Web.Services.Security / X509SecurityTokenTest.cs
blobb37d34206d6ee8bbee34b916f36e4bbc3606470b
1 //
2 // X509SecurityTokenTest.cs - NUnit Test Cases for X509SecurityToken
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
10 using NUnit.Framework;
11 using Microsoft.Web.Services.Security;
12 using Microsoft.Web.Services.Security.X509;
13 using System;
14 using System.ComponentModel; // for Win32Exception
15 using System.Reflection;
16 using System.Security.Cryptography;
17 using System.Xml;
19 namespace MonoTests.MS.Web.Services.Security {
21 [TestFixture]
22 public class X509SecurityTokenTest : Assertion {
24 // current but not trusted (test certificate)
25 private static byte[] cert1 = { 0x30, 0x82, 0x02, 0x2A, 0x30, 0x82, 0x01, 0x97, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x91, 0xC4, 0x4B, 0x0D, 0xB7, 0xD8, 0x10, 0x84, 0x42, 0x26, 0x71, 0xB3, 0x97, 0xB5, 0x00, 0x97, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x33, 0x30, 0x38, 0x31, 0x33, 0x30, 0x30, 0x34, 0x33, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x33, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35,
26 0x39, 0x35, 0x39, 0x5A, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x08, 0x46, 0x41, 0x52, 0x53, 0x43, 0x41, 0x50, 0x45, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xD2, 0xCB, 0x47, 0x21, 0xF5, 0x62, 0xDD, 0x35, 0xBF, 0x1D, 0xEC, 0x9A, 0x4C, 0x07, 0x2C, 0x01, 0xF0, 0x28, 0xC2, 0x82, 0x17, 0x8E, 0x58, 0x32, 0xD5, 0x4C, 0xAC, 0x86, 0xB4, 0xC9, 0xEB, 0x21, 0x26, 0xF3, 0x22, 0x30, 0xC5, 0x7A, 0xA3, 0x5A, 0xDD, 0x53, 0xAB, 0x1C, 0x06, 0x3E, 0xB2, 0x13, 0xC4, 0x05, 0x1D, 0x95, 0x8B, 0x0A, 0x71, 0x71, 0x11, 0xA7, 0x47, 0x26, 0x61, 0xF1,
27 0x76, 0xBE, 0x35, 0x72, 0x32, 0xC5, 0xCB, 0x47, 0xA4, 0x22, 0x41, 0x1E, 0xAD, 0x29, 0x11, 0x0D, 0x39, 0x22, 0x0C, 0x79, 0x90, 0xC6, 0x52, 0xA1, 0x10, 0xF6, 0x55, 0x09, 0x4E, 0x51, 0x26, 0x47, 0x0E, 0x94, 0xE6, 0x81, 0xF5, 0x18, 0x6B, 0x99, 0xF0, 0x76, 0xF3, 0xB2, 0x4C, 0x91, 0xE9, 0xBA, 0x3B, 0x3F, 0x6E, 0x63, 0xDA, 0x12, 0xD1, 0x0B, 0x73, 0x0E, 0x12, 0xC7, 0x70, 0x77, 0x22, 0x03, 0x9D, 0x5D, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x72, 0x30, 0x70, 0x30, 0x13, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x0C, 0x30, 0x0A, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x30, 0x59, 0x06, 0x03, 0x55, 0x1D, 0x01, 0x04, 0x52, 0x30, 0x50, 0x80, 0x10, 0xAE, 0xD7, 0x80, 0x88, 0xA6, 0x3D, 0xBA,
28 0x50, 0xA1, 0x7E, 0x57, 0xE5, 0x40, 0xC9, 0x6F, 0xC5, 0xA1, 0x2A, 0x30, 0x28, 0x31, 0x26, 0x30, 0x24, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x1D, 0x4D, 0x6F, 0x74, 0x75, 0x73, 0x20, 0x54, 0x65, 0x63, 0x68, 0x6E, 0x6F, 0x6C, 0x6F, 0x67, 0x69, 0x65, 0x73, 0x20, 0x69, 0x6E, 0x63, 0x2E, 0x28, 0x74, 0x65, 0x73, 0x74, 0x29, 0x82, 0x10, 0x9D, 0xAE, 0xA3, 0x39, 0x47, 0x0E, 0xD4, 0xA2, 0x49, 0x78, 0xEA, 0x6C, 0xBA, 0x0D, 0xDE, 0x9C, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x32, 0x8A, 0x7E, 0xAD, 0xE7, 0x67, 0x9E, 0x5C, 0x4C, 0xD8, 0x33, 0x59, 0x68, 0xCF, 0x94, 0xC0, 0x36, 0x47, 0x7A, 0xA7, 0x85, 0xC2, 0xDD, 0xD8, 0xDA, 0x11, 0x3C, 0x66, 0xC1, 0x83,
29 0xE3, 0xAB, 0x33, 0x06, 0x7C, 0xE3, 0x6A, 0x15, 0x72, 0xB8, 0x83, 0x3D, 0x0B, 0xAB, 0x3C, 0xEE, 0x75, 0x13, 0xBD, 0x5C, 0x96, 0x25, 0x56, 0x36, 0x05, 0xFA, 0xAE, 0xD4, 0xF4, 0xCF, 0x52, 0xEC, 0x11, 0xB5, 0xEA, 0x9F, 0x20, 0xA3, 0xC8, 0x34, 0x72, 0x59, 0x09, 0x51, 0xE7, 0x36, 0x87, 0x86, 0x86, 0x98, 0xB5, 0x30, 0x7B, 0xFB, 0x3D, 0xCC, 0x5E, 0xE8, 0xC9, 0x49, 0xE0, 0xC6, 0xEA, 0x02, 0x76, 0x01, 0xE0, 0xBB, 0x8A, 0x70, 0xEB, 0x07, 0x86, 0xE8, 0x04, 0xE7, 0x48, 0xE4, 0x6C, 0x90, 0xE6, 0x16, 0x42, 0xB4, 0xBB, 0xC0, 0xC4, 0x82, 0x5F, 0xF8, 0xFB, 0x7E, 0xB2, 0x9E, 0xC2, 0x78, 0x26, 0x86 };
31 // this certificate isn't current
32 private static byte[] cert2 = { 0x30,0x82,0x09,0xB9,0x30,0x82,0x09,0x22,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x20,0x0B,0x35,0x5E,0xCE,0xC4,0xB0,0x63,0xB7,0xDE,0xC6,0x34,0xB9,0x70,0x34,0x44,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x62,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x13,0x08,0x49,0x6E,0x74,0x65,0x72,0x6E,0x65,0x74,0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0A,0x13,0x0E,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x34,0x30,0x32,0x06,0x03,0x55,0x04,0x0B,
33 0x13,0x2B,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x43,0x41,0x20,0x2D,0x20,0x49,0x6E,0x64,0x69,0x76,0x69,0x64,0x75,0x61,0x6C,0x20,0x53,0x75,0x62,0x73,0x63,0x72,0x69,0x62,0x65,0x72,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x38,0x32,0x31,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x39,0x37,0x30,0x38,0x32,0x30,0x32,0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x82,0x01,0x0A,0x31,0x11,0x30,0x0F,0x06,0x03,0x55,0x04,0x07,0x13,0x08,0x49,0x6E,0x74,0x65,0x72,0x6E,0x65,0x74,
34 0x31,0x17,0x30,0x15,0x06,0x03,0x55,0x04,0x0A,0x13,0x0E,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x34,0x30,0x32,0x06,0x03,0x55,0x04,0x0B,0x13,0x2B,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x43,0x41,0x20,0x2D,0x20,0x49,0x6E,0x64,0x69,0x76,0x69,0x64,0x75,0x61,0x6C,0x20,0x53,0x75,0x62,0x73,0x63,0x72,0x69,0x62,0x65,0x72,0x31,0x46,0x30,0x44,0x06,0x03,0x55,0x04,0x0B,0x13,0x3D,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,
35 0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,0x72,0x79,0x2F,0x43,0x50,0x53,0x20,0x49,0x6E,0x63,0x6F,0x72,0x70,0x2E,0x20,0x62,0x79,0x20,0x52,0x65,0x66,0x2E,0x2C,0x4C,0x49,0x41,0x42,0x2E,0x4C,0x54,0x44,0x28,0x63,0x29,0x39,0x36,0x31,0x26,0x30,0x24,0x06,0x03,0x55,0x04,0x0B,0x13,0x1D,0x44,0x69,0x67,0x69,0x74,0x61,0x6C,0x20,0x49,0x44,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x2D,0x20,0x4E,0x65,0x74,0x73,0x63,0x61,0x70,0x65,0x31,0x16,0x30,0x14,0x06,0x03,0x55,0x04,0x03,
36 0x13,0x0D,0x44,0x61,0x76,0x69,0x64,0x20,0x54,0x2E,0x20,0x47,0x72,0x61,0x79,0x31,0x1E,0x30,0x1C,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,0x16,0x0F,0x64,0x61,0x76,0x69,0x64,0x40,0x66,0x6F,0x72,0x6D,0x61,0x6C,0x2E,0x69,0x65,0x30,0x5C,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x4B,0x00,0x30,0x48,0x02,0x41,0x00,0xC5,0x81,0x07,0xA2,0xEB,0x0F,0xB8,0xFF,0xF8,0xF8,0x1C,0xEE,0x32,0xFF,0xBF,0x12,0x35,0x6A,0xF9,0x6B,0xC8,0xBE,0x2F,0xFB,0x3E,0xAF,0x04,0x51,
37 0x4A,0xAC,0xDD,0x10,0x29,0xA8,0xCD,0x40,0x5B,0x66,0x1E,0x98,0xEF,0xF2,0x4C,0x77,0xFA,0x8F,0x86,0xD1,0x21,0x67,0x92,0x44,0x4A,0xC4,0x89,0xC9,0x83,0xCF,0x88,0x9F,0x6F,0xE2,0x32,0x35,0x02,0x03,0x01,0x00,0x01,0xA3,0x82,0x07,0x08,0x30,0x82,0x07,0x04,0x30,0x09,0x06,0x03,0x55,0x1D,0x13,0x04,0x02,0x30,0x00,0x30,0x82,0x02,0x1F,0x06,0x03,0x55,0x1D,0x03,0x04,0x82,0x02,0x16,0x30,0x82,0x02,0x12,0x30,0x82,0x02,0x0E,0x30,0x82,0x02,0x0A,0x06,0x0B,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x30,0x82,
38 0x01,0xF9,0x16,0x82,0x01,0xA7,0x54,0x68,0x69,0x73,0x20,0x63,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x69,0x6E,0x63,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x65,0x73,0x20,0x62,0x79,0x20,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x2C,0x20,0x61,0x6E,0x64,0x20,0x69,0x74,0x73,0x20,0x75,0x73,0x65,0x20,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x63,0x74,0x6C,0x79,0x20,0x73,0x75,0x62,0x6A,0x65,0x63,0x74,0x20,0x74,0x6F,0x2C,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,
39 0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x50,0x72,0x61,0x63,0x74,0x69,0x63,0x65,0x20,0x53,0x74,0x61,0x74,0x65,0x6D,0x65,0x6E,0x74,0x20,0x28,0x43,0x50,0x53,0x29,0x2C,0x20,0x61,0x76,0x61,0x69,0x6C,0x61,0x62,0x6C,0x65,0x20,0x61,0x74,0x3A,0x20,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x43,0x50,0x53,0x3B,0x20,0x62,0x79,0x20,0x45,0x2D,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x20,0x43,0x50,0x53,0x2D,
40 0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x73,0x40,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x3B,0x20,0x6F,0x72,0x20,0x62,0x79,0x20,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x2C,0x20,0x32,0x35,0x39,0x33,0x20,0x43,0x6F,0x61,0x73,0x74,0x20,0x41,0x76,0x65,0x2E,0x2C,0x20,0x4D,0x6F,0x75,0x6E,0x74,0x61,0x69,0x6E,0x20,0x56,0x69,0x65,0x77,0x2C,0x20,0x43,0x41,0x20,0x39,0x34,0x30,0x34,0x33,0x20,0x55,0x53,0x41,0x20,0x54,0x65,
41 0x6C,0x2E,0x20,0x2B,0x31,0x20,0x28,0x34,0x31,0x35,0x29,0x20,0x39,0x36,0x31,0x2D,0x38,0x38,0x33,0x30,0x20,0x43,0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x20,0x31,0x39,0x39,0x36,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x20,0x20,0x41,0x6C,0x6C,0x20,0x52,0x69,0x67,0x68,0x74,0x73,0x20,0x52,0x65,0x73,0x65,0x72,0x76,0x65,0x64,0x2E,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x20,0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x20,0x44,0x49,0x53,0x43,
42 0x4C,0x41,0x49,0x4D,0x45,0x44,0x20,0x61,0x6E,0x64,0x20,0x4C,0x49,0x41,0x42,0x49,0x4C,0x49,0x54,0x59,0x20,0x4C,0x49,0x4D,0x49,0x54,0x45,0x44,0x2E,0xA0,0x0E,0x06,0x0C,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x01,0xA1,0x0E,0x06,0x0C,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x02,0x30,0x2C,0x30,0x2A,0x16,0x28,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,
43 0x72,0x79,0x2F,0x43,0x50,0x53,0x20,0x30,0x11,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,0x04,0x04,0x03,0x02,0x07,0x80,0x30,0x36,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x08,0x04,0x29,0x16,0x27,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,0x72,0x79,0x2F,0x43,0x50,0x53,0x30,0x82,0x04,0x87,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,0x04,0x82,0x04,
44 0x78,0x16,0x82,0x04,0x74,0x43,0x41,0x55,0x54,0x49,0x4F,0x4E,0x3A,0x20,0x54,0x68,0x65,0x20,0x43,0x6F,0x6D,0x6D,0x6F,0x6E,0x20,0x4E,0x61,0x6D,0x65,0x20,0x69,0x6E,0x20,0x74,0x68,0x69,0x73,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x31,0x20,0x44,0x69,0x67,0x69,0x74,0x61,0x6C,0x20,0x0A,0x49,0x44,0x20,0x69,0x73,0x20,0x6E,0x6F,0x74,0x20,0x61,0x75,0x74,0x68,0x65,0x6E,0x74,0x69,0x63,0x61,0x74,0x65,0x64,0x20,0x62,0x79,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2E,0x20,0x49,0x74,0x20,0x6D,0x61,0x79,0x20,0x62,
45 0x65,0x20,0x74,0x68,0x65,0x0A,0x68,0x6F,0x6C,0x64,0x65,0x72,0x27,0x73,0x20,0x72,0x65,0x61,0x6C,0x20,0x6E,0x61,0x6D,0x65,0x20,0x6F,0x72,0x20,0x61,0x6E,0x20,0x61,0x6C,0x69,0x61,0x73,0x2E,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x64,0x6F,0x65,0x73,0x20,0x61,0x75,0x74,0x68,0x2D,0x0A,0x65,0x6E,0x74,0x69,0x63,0x61,0x74,0x65,0x20,0x74,0x68,0x65,0x20,0x65,0x2D,0x6D,0x61,0x69,0x6C,0x20,0x61,0x64,0x64,0x72,0x65,0x73,0x73,0x20,0x6F,0x66,0x20,0x74,0x68,0x65,0x20,0x68,0x6F,0x6C,0x64,0x65,0x72,0x2E,
46 0x0A,0x0A,0x54,0x68,0x69,0x73,0x20,0x63,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x20,0x69,0x6E,0x63,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x65,0x73,0x20,0x62,0x79,0x20,0x72,0x65,0x66,0x65,0x72,0x65,0x6E,0x63,0x65,0x2C,0x20,0x61,0x6E,0x64,0x20,0x0A,0x69,0x74,0x73,0x20,0x75,0x73,0x65,0x20,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x63,0x74,0x6C,0x79,0x20,0x73,0x75,0x62,0x6A,0x65,0x63,0x74,0x20,0x74,0x6F,0x2C,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x0A,0x43,0x65,0x72,
47 0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x50,0x72,0x61,0x63,0x74,0x69,0x63,0x65,0x20,0x53,0x74,0x61,0x74,0x65,0x6D,0x65,0x6E,0x74,0x20,0x28,0x43,0x50,0x53,0x29,0x2C,0x20,0x61,0x76,0x61,0x69,0x6C,0x61,0x62,0x6C,0x65,0x0A,0x69,0x6E,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x72,0x65,0x70,0x6F,0x73,0x69,0x74,0x6F,0x72,0x79,0x20,0x61,0x74,0x3A,0x20,0x0A,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,
48 0x63,0x6F,0x6D,0x3B,0x20,0x62,0x79,0x20,0x45,0x2D,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x0A,0x43,0x50,0x53,0x2D,0x72,0x65,0x71,0x75,0x65,0x73,0x74,0x73,0x40,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x3B,0x20,0x6F,0x72,0x20,0x62,0x79,0x20,0x6D,0x61,0x69,0x6C,0x20,0x61,0x74,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x0A,0x49,0x6E,0x63,0x2E,0x2C,0x20,0x32,0x35,0x39,0x33,0x20,0x43,0x6F,0x61,0x73,0x74,0x20,0x41,0x76,0x65,0x2E,0x2C,0x20,0x4D,0x6F,0x75,0x6E,0x74,0x61,0x69,0x6E,
49 0x20,0x56,0x69,0x65,0x77,0x2C,0x20,0x43,0x41,0x20,0x39,0x34,0x30,0x34,0x33,0x20,0x55,0x53,0x41,0x0A,0x0A,0x43,0x6F,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,0x28,0x63,0x29,0x31,0x39,0x39,0x36,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x20,0x20,0x41,0x6C,0x6C,0x20,0x52,0x69,0x67,0x68,0x74,0x73,0x20,0x0A,0x52,0x65,0x73,0x65,0x72,0x76,0x65,0x64,0x2E,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x20,0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x20,0x44,0x49,0x53,0x43,
50 0x4C,0x41,0x49,0x4D,0x45,0x44,0x20,0x41,0x4E,0x44,0x20,0x0A,0x4C,0x49,0x41,0x42,0x49,0x4C,0x49,0x54,0x59,0x20,0x4C,0x49,0x4D,0x49,0x54,0x45,0x44,0x2E,0x0A,0x0A,0x57,0x41,0x52,0x4E,0x49,0x4E,0x47,0x3A,0x20,0x54,0x48,0x45,0x20,0x55,0x53,0x45,0x20,0x4F,0x46,0x20,0x54,0x48,0x49,0x53,0x20,0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x20,0x49,0x53,0x20,0x53,0x54,0x52,0x49,0x43,0x54,0x4C,0x59,0x0A,0x53,0x55,0x42,0x4A,0x45,0x43,0x54,0x20,0x54,0x4F,0x20,0x54,0x48,0x45,0x20,0x56,0x45,0x52,0x49,
51 0x53,0x49,0x47,0x4E,0x20,0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x49,0x4F,0x4E,0x20,0x50,0x52,0x41,0x43,0x54,0x49,0x43,0x45,0x0A,0x53,0x54,0x41,0x54,0x45,0x4D,0x45,0x4E,0x54,0x2E,0x20,0x20,0x54,0x48,0x45,0x20,0x49,0x53,0x53,0x55,0x49,0x4E,0x47,0x20,0x41,0x55,0x54,0x48,0x4F,0x52,0x49,0x54,0x59,0x20,0x44,0x49,0x53,0x43,0x4C,0x41,0x49,0x4D,0x53,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x0A,0x49,0x4D,0x50,0x4C,0x49,0x45,0x44,0x20,0x41,0x4E,0x44,0x20,0x45,0x58,0x50,0x52,0x45,0x53,0x53,0x20,
52 0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x2C,0x20,0x49,0x4E,0x43,0x4C,0x55,0x44,0x49,0x4E,0x47,0x20,0x57,0x41,0x52,0x52,0x41,0x4E,0x54,0x49,0x45,0x53,0x0A,0x4F,0x46,0x20,0x4D,0x45,0x52,0x43,0x48,0x41,0x4E,0x54,0x41,0x42,0x49,0x4C,0x49,0x54,0x59,0x20,0x4F,0x52,0x20,0x46,0x49,0x54,0x4E,0x45,0x53,0x53,0x20,0x46,0x4F,0x52,0x20,0x41,0x20,0x50,0x41,0x52,0x54,0x49,0x43,0x55,0x4C,0x41,0x52,0x0A,0x50,0x55,0x52,0x50,0x4F,0x53,0x45,0x2C,0x20,0x41,0x4E,0x44,0x20,0x57,0x49,0x4C,0x4C,0x20,0x4E,0x4F,
53 0x54,0x20,0x42,0x45,0x20,0x4C,0x49,0x41,0x42,0x4C,0x45,0x20,0x46,0x4F,0x52,0x20,0x43,0x4F,0x4E,0x53,0x45,0x51,0x55,0x45,0x4E,0x54,0x49,0x41,0x4C,0x2C,0x0A,0x50,0x55,0x4E,0x49,0x54,0x49,0x56,0x45,0x2C,0x20,0x41,0x4E,0x44,0x20,0x43,0x45,0x52,0x54,0x41,0x49,0x4E,0x20,0x4F,0x54,0x48,0x45,0x52,0x20,0x44,0x41,0x4D,0x41,0x47,0x45,0x53,0x2E,0x20,0x53,0x45,0x45,0x20,0x54,0x48,0x45,0x20,0x43,0x50,0x53,0x0A,0x46,0x4F,0x52,0x20,0x44,0x45,0x54,0x41,0x49,0x4C,0x53,0x2E,0x0A,0x0A,0x43,0x6F,0x6E,0x74,0x65,0x6E,
54 0x74,0x73,0x20,0x6F,0x66,0x20,0x74,0x68,0x65,0x20,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x65,0x64,0x0A,0x6E,0x6F,0x6E,0x76,0x65,0x72,0x69,0x66,0x69,0x65,0x64,0x53,0x75,0x62,0x6A,0x65,0x63,0x74,0x41,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x73,0x20,0x65,0x78,0x74,0x65,0x6E,0x73,0x69,0x6F,0x6E,0x20,0x76,0x61,0x6C,0x75,0x65,0x20,0x73,0x68,0x61,0x6C,0x6C,0x20,0x0A,0x6E,0x6F,0x74,0x20,0x62,0x65,0x20,0x63,0x6F,0x6E,0x73,0x69,0x64,0x65,0x72,0x65,0x64,0x20,
55 0x61,0x73,0x20,0x61,0x63,0x63,0x75,0x72,0x61,0x74,0x65,0x20,0x69,0x6E,0x66,0x6F,0x72,0x6D,0x61,0x74,0x69,0x6F,0x6E,0x20,0x76,0x61,0x6C,0x69,0x64,0x61,0x74,0x65,0x64,0x20,0x0A,0x62,0x79,0x20,0x74,0x68,0x65,0x20,0x49,0x41,0x2E,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0x2B,0x3D,0x44,0xC7,0x32,0x59,0xAE,0xF1,0x5F,0x8F,0x3F,0x87,0xE3,0x3E,0xEB,0x81,0x30,0xF8,0xA9,0x96,0xDB,0x01,0x42,0x0B,0x04,0xEF,0x37,0x02,0x3F,0xD4,0x20,0x61,0x58,0xC4,0x4A,0x3A,
56 0x39,0xB3,0xFB,0xD9,0xF8,0xA5,0xC4,0x5E,0x33,0x5A,0x0E,0xFA,0x93,0x56,0x2F,0x6F,0xD6,0x61,0xA2,0xAF,0xA5,0x0C,0x1D,0xE2,0x41,0x65,0xF3,0x40,0x75,0x66,0x83,0xD2,0x5A,0xB4,0xB7,0x56,0x0B,0x8E,0x0D,0xA1,0x33,0x13,0x7D,0x49,0xC3,0xB1,0x00,0x68,0x83,0x7F,0xB5,0x66,0xD4,0x32,0x32,0xFE,0x8B,0x9A,0x5A,0xD6,0x01,0x72,0x31,0x5D,0x85,0x91,0xBC,0x93,0x9B,0x65,0x60,0x25,0xC6,0x1F,0xBC,0xDD,0x69,0x44,0x62,0xC2,0xB2,0x6F,0x46,0xAB,0x2F,0x20,0xA5,0x6F,0xDA,0x48,0x6C,0x9C };
58 public const string xml = "<wsse:BinarySecurityToken ValueType=\"wsse:X509v3\" EncodingType=\"wsse:Base64Binary\" xmlns:wsu=\"http://schemas.xmlsoap.org/ws/2002/07/utility\" wsu:Id=\"SecurityToken-9a43da12-9834-4119-a3c4-c042bdc56b25\" xmlns:wsse=\"http://schemas.xmlsoap.org/ws/2002/07/secext\">MIICKjCCAZegAwIBAgIQkcRLDbfYEIRCJnGzl7UAlzAJBgUrDgMCHQUAMCgxJjAkBgNVBAMTHU1vdHVzIFRlY2hub2xvZ2llcyBpbmMuKHRlc3QpMB4XDTAzMDgxMzAwNDM0N1oXDTM5MTIzMTIzNTk1OVowEzERMA8GA1UEAxMIRkFSU0NBUEUwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANLLRyH1Yt01vx3smkwHLAHwKMKCF45YMtVMrIa0yeshJvMiMMV6o1rdU6scBj6yE8QFHZWLCnFxEadHJmHxdr41cjLFy0ekIkEerSkRDTkiDHmQxlKhEPZVCU5RJkcOlOaB9RhrmfB287JMkem6Oz9uY9oS0QtzDhLHcHciA51dAgMBAAGjcjBwMBMGA1UdJQQMMAoGCCsGAQUFBwMBMFkGA1UdAQRSMFCAEK7XgIimPbpQoX5X5UDJb8WhKjAoMSYwJAYDVQQDEx1Nb3R1cyBUZWNobm9sb2dpZXMgaW5jLih0ZXN0KYIQna6jOUcO1KJJeOpsug3enDAJBgUrDgMCHQUAA4GBADKKfq3nZ55cTNgzWWjPlMA2R3qnhcLd2NoRPGbBg+OrMwZ842oVcriDPQurPO51E71cliVWNgX6rtT0z1LsEbXqnyCjyDRyWQlR5zaHhoaYtTB7+z3MXujJSeDG6gJ2AeC7inDrB4boBOdI5GyQ5hZCtLvAxIJf+Pt+sp7CeCaG</wsse:BinarySecurityToken>";
60 private void CheckValueType (X509SecurityToken xst)
62 AssertNotNull ("ValueType!=null", xst);
63 Assert ("ValueType.IsEmpty", !xst.ValueType.IsEmpty);
64 AssertEquals ("ValueType.Name", "X509v3", xst.ValueType.Name);
65 AssertEquals ("ValueType.Namespace", WSSecurity.NamespaceURI, xst.ValueType.Namespace);
68 [Test]
69 public void ConstructorX509 ()
71 X509Certificate x = new X509Certificate (cert1);
72 X509SecurityToken xst = new X509SecurityToken (x);
73 AssertNotNull ("X509SecurityToken(X509Certificate)", xst);
74 AssertNotNull ("X509SecurityToken.Certificate", xst.Certificate);
75 AssertNotNull ("X509SecurityToken.RawData", xst.RawData);
76 // check "static" properties (no need to do it for every certificate)
77 Assert ("EncodingType.IsEmpty", !xst.EncodingType.IsEmpty);
78 AssertEquals ("EncodingType.Name", "Base64Binary", xst.EncodingType.Name);
79 AssertEquals ("EncodingType.Namespace", WSSecurity.NamespaceURI, xst.EncodingType.Namespace);
80 CheckValueType (xst);
83 [Test]
84 [ExpectedException (typeof (ArgumentNullException))]
85 public void ConstructorX509Null ()
87 X509Certificate x = null;
88 X509SecurityToken xst = new X509SecurityToken (x);
91 [Test]
92 public void ConstructorXmlElement ()
94 XmlDocument doc = new XmlDocument ();
95 doc.LoadXml (xml);
96 X509SecurityToken xst = new X509SecurityToken (doc.DocumentElement);
97 AssertNotNull ("X509SecurityToken(XmlElement)", xst);
98 AssertNotNull ("X509SecurityToken.Certificate", xst.Certificate);
99 // check "static" properties (no need to do it for every certificate)
100 Assert ("EncodingType.IsEmpty", !xst.EncodingType.IsEmpty);
101 AssertEquals ("EncodingType.Name", "Base64Binary", xst.EncodingType.Name);
102 AssertEquals ("EncodingType.Namespace", WSSecurity.NamespaceURI, xst.EncodingType.Namespace);
103 Assert ("ValueType.IsEmpty", !xst.ValueType.IsEmpty);
104 AssertEquals ("ValueType.Name", "X509v3", xst.ValueType.Name);
105 AssertEquals ("ValueType.Namespace", WSSecurity.NamespaceURI, xst.ValueType.Namespace);
108 [Test]
109 [ExpectedException (typeof (ArgumentNullException))]
110 public void ConstructorXmlElementNull ()
112 XmlElement xel = null;
113 X509SecurityToken xst = new X509SecurityToken (xel);
116 [Test]
117 public void Certificate ()
119 X509Certificate x = new X509Certificate (cert1);
120 X509SecurityToken xst = new X509SecurityToken (x);
121 AssertEquals ("X509SecurityToken.Certificate", BitConverter.ToString (cert1), BitConverter.ToString (xst.Certificate.GetRawCertData ()));
124 [Test]
125 // LAMESPEC: [ExpectedException (typeof (ArgumentNullException))]
126 public void CertificateNull ()
128 X509Certificate x = new X509Certificate (cert1);
129 X509SecurityToken xst = new X509SecurityToken (x);
130 xst.Certificate = null;
131 // oops - many things can go wrong if the certificate is null!
132 // so I think it's a bug, not just some lame spec
133 AssertNull (xst.Certificate);
136 [Test]
137 public void NullCertificateRawData ()
139 X509Certificate x = new X509Certificate (cert1);
140 X509SecurityToken xst = new X509SecurityToken (x);
141 xst.Certificate = null;
142 byte[] rd = xst.RawData;
143 AssertNull ("(Certificate==null).RawData", rd);
146 [Test]
147 // supports both DigitalSignature and DataEncryption
148 public void TestCertificate1 ()
150 X509Certificate x = new X509Certificate (cert1);
151 X509SecurityToken xst = new X509SecurityToken (x);
152 // check properties
153 AssertEquals ("RawData.Length", cert1.Length, xst.RawData.Length);
154 Assert ("Certificate1.SupportsDigitalSignature", xst.SupportsDigitalSignature);
155 AssertNotNull ("Certificate1.AuthenticationKey", xst.AuthenticationKey);
156 Assert ("Certificate1.SupportsDataEncryption", xst.SupportsDataEncryption);
157 AssertNotNull ("Certificate1.EncryptionKey", xst.EncryptionKey);
160 [Test]
161 // supports both DigitalSignature and DataEncryption
162 public void TestCertificate2 ()
164 X509Certificate x = new X509Certificate (cert2);
165 X509SecurityToken xst = new X509SecurityToken (x);
166 // check properties
167 AssertEquals ("RawData.Length", cert2.Length, xst.RawData.Length);
168 Assert ("Certificate2.SupportsDigitalSignature", xst.SupportsDigitalSignature);
169 AssertNotNull ("Certificate2.AuthenticationKey", xst.AuthenticationKey);
170 Assert ("Certificate2.SupportsDataEncryption", xst.SupportsDataEncryption);
171 AssertNotNull ("Certificate2.EncryptionKey", xst.EncryptionKey);
174 [Test]
175 public void GetXml ()
177 X509Certificate x = new X509Certificate (cert1);
178 X509SecurityToken xst = new X509SecurityToken (x);
179 XmlDocument doc = new XmlDocument ();
180 XmlElement xel = xst.GetXml (doc);
181 AssertEquals ("XML length", xml.Length, xel.OuterXml.Length);
184 [Test]
185 [ExpectedException (typeof (ArgumentNullException))]
186 public void GetXmlNull ()
188 X509Certificate x = new X509Certificate (cert1);
189 X509SecurityToken xst = new X509SecurityToken (x);
190 xst.GetXml (null);
193 [Test]
194 public void LoadXml ()
196 X509Certificate x = new X509Certificate (cert2);
197 X509SecurityToken xst = new X509SecurityToken (x);
198 XmlDocument doc = new XmlDocument ();
199 doc.LoadXml (xml);
200 xst.LoadXml (doc.DocumentElement);
201 CheckValueType (xst);
202 AssertEquals ("Same cert", BitConverter.ToString (cert1), BitConverter.ToString (xst.RawData));
205 [Test]
206 [ExpectedException (typeof (ArgumentNullException))]
207 public void LoadXmlNull ()
209 X509Certificate x = new X509Certificate (cert1);
210 X509SecurityToken xst = new X509SecurityToken (x);
211 xst.LoadXml (null);
214 [Test]
215 public void AuthenticationKey ()
217 X509Certificate x = new X509Certificate (cert1);
218 X509SecurityToken xst = new X509SecurityToken (x);
219 AssertNotNull ("Certificate1.AuthenticationKey", xst.AuthenticationKey);
220 Assert ("X509Certificate.SupportsDigitalSignature", x.SupportsDigitalSignature);
223 [Test]
224 [ExpectedException (typeof (InvalidOperationException))]
225 public void NullCertificateAuthenticationKey ()
227 X509Certificate x = new X509Certificate (cert1);
228 X509SecurityToken xst = new X509SecurityToken (x);
229 xst.Certificate = null;
230 AssertNotNull ("(Certificate==null).AuthenticationKey", xst.AuthenticationKey);
233 [Test]
234 [Ignore ("need to complete X509Store")]
235 public void DecryptionKey ()
237 // TODO with a certificate associated with a private key
240 [Test]
241 [ExpectedException (typeof (InvalidOperationException))]
242 public void NullCertificateDecryptionKey ()
244 X509Certificate x = new X509Certificate (cert1);
245 X509SecurityToken xst = new X509SecurityToken (x);
246 xst.Certificate = null;
247 AssertNotNull ("(Certificate==null).DecryptionKey", xst.DecryptionKey);
250 [Test]
251 [ExpectedException (typeof (Win32Exception))]
252 public void CertificateWithoutPrivateKeyDecryptionKey ()
254 X509Certificate x = new X509Certificate (cert2);
255 X509SecurityToken xst = new X509SecurityToken (x);
256 AssertNotNull ("Certificate2.DecryptionKey", xst.DecryptionKey);
257 Assert ("X509Certificate.SupportsDataEncryption", x.SupportsDataEncryption);
260 [Test]
261 public void EncryptionKey ()
263 X509Certificate x = new X509Certificate (cert1);
264 X509SecurityToken xst = new X509SecurityToken (x);
265 AssertNotNull ("Certificate1.EncryptionKey", xst.EncryptionKey);
266 Assert ("X509Certificate.SupportsDataEncryption", x.SupportsDataEncryption);
269 [Test]
270 [ExpectedException (typeof (InvalidOperationException))]
271 public void NullCertificateEncryptionKey ()
273 X509Certificate x = new X509Certificate (cert1);
274 X509SecurityToken xst = new X509SecurityToken (x);
275 xst.Certificate = null;
276 AssertNotNull ("(Certificate==null).EncryptionKey", xst.EncryptionKey);
279 [Test]
280 public void RawData ()
282 X509Certificate x = new X509Certificate (cert1);
283 X509SecurityToken xst = new X509SecurityToken (x);
284 AssertEquals ("RawData1", BitConverter.ToString (cert1), BitConverter.ToString (xst.RawData));
285 // kind of indirect null
286 xst.Certificate = null;
287 AssertNull ("(Certificate==null).RawData", xst.RawData);
288 xst.RawData = cert1;
289 AssertEquals ("RawData2", BitConverter.ToString (cert1), BitConverter.ToString (xst.RawData));
292 [Test]
293 [ExpectedException (typeof (ArgumentNullException))]
294 public void RawDataNull ()
296 X509Certificate x = new X509Certificate (cert1);
297 X509SecurityToken xst = new X509SecurityToken (x);
298 xst.RawData = null;
301 [Test]
302 [Ignore ("need to complete X509Store")]
303 public void SignatureKey ()
305 // TODO with a certificate associated with a private key
308 [Test]
309 [ExpectedException (typeof (InvalidOperationException))]
310 public void NullCertificateSignatureKey ()
312 X509Certificate x = new X509Certificate (cert1);
313 X509SecurityToken xst = new X509SecurityToken (x);
314 xst.Certificate = null;
315 AssertNotNull ("(Certificate==null).SignatureKey", xst.SignatureKey);
318 [Test]
319 [ExpectedException (typeof (Win32Exception))]
320 public void CertificateWithoutPrivateKeySignatureKey ()
322 X509Certificate x = new X509Certificate (cert2);
323 X509SecurityToken xst = new X509SecurityToken (x);
324 AssertNotNull ("Certificate2.SignatureKey", xst.SignatureKey);
325 Assert ("X509Certificate.SupportsDigitalSignature", x.SupportsDigitalSignature);
328 [Test]
329 public void SupportsDataEncryption ()
331 X509Certificate x = new X509Certificate (cert1);
332 X509SecurityToken xst = new X509SecurityToken (x);
333 Assert ("SupportsDataEncryption", xst.SupportsDataEncryption);
336 [Test]
337 [ExpectedException (typeof (InvalidOperationException))]
338 public void NullCertificateSupportsDataEncryption ()
340 X509Certificate x = new X509Certificate (cert1);
341 X509SecurityToken xst = new X509SecurityToken (x);
342 xst.Certificate = null;
343 Assert ("(Certificate==null).SupportsDataEncryption", xst.SupportsDataEncryption);
346 [Test]
347 public void SupportsDigitalSignature ()
349 X509Certificate x = new X509Certificate (cert1);
350 X509SecurityToken xst = new X509SecurityToken (x);
351 Assert ("SupportsDigitalSignature", xst.SupportsDigitalSignature);
354 [Test]
355 [ExpectedException (typeof (InvalidOperationException))]
356 public void NullCertificateSupportsDigitalSignature ()
358 X509Certificate x = new X509Certificate (cert1);
359 X509SecurityToken xst = new X509SecurityToken (x);
360 xst.Certificate = null;
361 Assert ("(Certificate==null).SupportsDigitalSignature", xst.SupportsDigitalSignature);
364 [Test]
365 public void NullCertificateValueType ()
367 X509Certificate x = new X509Certificate (cert1);
368 X509SecurityToken xst = new X509SecurityToken (x);
369 // is ValueType related to certificate presence ?
370 xst.Certificate = null;
371 CheckValueType (xst);
374 [Test]
375 public void ValueType ()
377 X509Certificate x = new X509Certificate (cert1);
378 X509SecurityToken xst = new X509SecurityToken (x);
379 XmlQualifiedName qn = new XmlQualifiedName ("X509v3", WSSecurity.NamespaceURI);
380 xst.ValueType = qn;
383 [Test]
384 [ExpectedException (typeof (SecurityFormatException))]
385 public void ValueTypeInvalidName ()
387 X509Certificate x = new X509Certificate (cert1);
388 X509SecurityToken xst = new X509SecurityToken (x);
389 XmlQualifiedName qn = new XmlQualifiedName ("?", WSSecurity.NamespaceURI);
390 xst.ValueType = qn;
393 [Test]
394 [ExpectedException (typeof (SecurityFormatException))]
395 public void ValueTypeInvalidNamespace ()
397 X509Certificate x = new X509Certificate (cert1);
398 X509SecurityToken xst = new X509SecurityToken (x);
399 XmlQualifiedName qn = new XmlQualifiedName ("X509v3", "?");
400 xst.ValueType = qn;
403 [Test]
404 [Ignore ("strangely MS code signing cert seems invalid - need another candidate")]
405 public void Verify ()
407 X509Certificate x = new X509Certificate (null);
408 X509SecurityToken xst = new X509SecurityToken (x);
409 xst.Verify ();
410 // ok if not exception is thrown
413 [Test]
414 // [ExpectedException (typeof (SecurityFault))] SecurityFault is internal
415 public void VerifyNullCertificate ()
417 X509Certificate x = new X509Certificate (cert1);
418 X509SecurityToken xst = new X509SecurityToken (x);
419 xst.Certificate = null;
420 try {
421 xst.Verify ();
423 catch (Exception e) {
424 if (!e.ToString ().StartsWith ("Microsoft.Web.Services.Security.SecurityFault"))
425 Fail ("expected SecurityFault");
429 [Test]
430 // [ExpectedException (typeof (SecurityFault))] SecurityFault is internal
431 public void VerifyCertificateNotCurrent ()
433 X509Certificate x = new X509Certificate (cert2);
434 X509SecurityToken xst = new X509SecurityToken (x);
435 try {
436 xst.Verify ();
438 catch (Exception e) {
439 if (!e.ToString ().StartsWith ("Microsoft.Web.Services.Security.SecurityFault"))
440 Fail ("expected SecurityFault");