private void TbsV1CertGenerate() { V1TbsCertificateGenerator gen = new V1TbsCertificateGenerator(); DateTime startDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 1); DateTime endDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 12); gen.SetSerialNumber(new DerInteger(1)); gen.SetStartDate(new Time(startDate)); gen.SetEndDate(new Time(endDate)); gen.SetIssuer(new X509Name("CN=AU,O=Bouncy Castle")); gen.SetSubject(new X509Name("CN=AU,O=Bouncy Castle,OU=Test 1")); gen.SetSignature(new AlgorithmIdentifier(PkcsObjectIdentifiers.MD5WithRsaEncryption, DerNull.Instance)); SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PkcsObjectIdentifiers.RsaEncryption, DerNull.Instance), new RsaPublicKeyStructure(BigInteger.One, BigInteger.Two)); gen.SetSubjectPublicKeyInfo(info); TbsCertificateStructure tbs = gen.GenerateTbsCertificate(); if (!Arrays.AreEqual(tbs.GetEncoded(), v1Cert)) { Fail("failed v1 cert generation"); } // // read back test // Asn1InputStream aIn = new Asn1InputStream(v1Cert); Asn1Object o = aIn.ReadObject(); if (!Arrays.AreEqual(o.GetEncoded(), v1Cert)) { Fail("failed v1 cert read back test"); } }
/// <summary> /// Set the date after which this certificate will no longer be valid. /// </summary> /// <param name="date"/> public void SetNotAfter( DateTime date) { tbsGen.SetEndDate(new Time(date)); }
public void SetNotAfter(global::System.DateTime date) { tbsGen.SetEndDate(new Time(date)); }