public virtual bool IsValid(global::System.DateTime time) { if (time.CompareTo((object)NotBefore) >= 0) { return(time.CompareTo((object)NotAfter) <= 0); } return(false); }
public virtual void CheckValidity(global::System.DateTime time) { if (time.CompareTo((object)NotAfter) > 0) { throw new CertificateExpiredException("certificate expired on " + c.EndDate.GetTime()); } if (time.CompareTo((object)NotBefore) < 0) { throw new CertificateNotYetValidException("certificate not valid until " + c.StartDate.GetTime()); } }
public virtual void CheckValidity(global::System.DateTime date) { if (date.CompareTo((object)NotAfter) > 0) { throw new CertificateExpiredException(string.Concat((object)"certificate expired on ", (object)NotAfter)); } if (date.CompareTo((object)NotBefore) < 0) { throw new CertificateNotYetValidException(string.Concat((object)"certificate not valid until ", (object)NotBefore)); } }
private static void CheckCrl(DistributionPoint dp, IX509AttributeCertificate attrCert, PkixParameters paramsPKIX, global::System.DateTime validDate, X509Certificate issuerCert, CertStatus certStatus, ReasonsMask reasonMask, global::System.Collections.IList certPathCerts) { if (attrCert.GetExtensionValue(X509Extensions.NoRevAvail) != null) { return; } global::System.DateTime utcNow = global::System.DateTime.get_UtcNow(); if (validDate.CompareTo((object)utcNow) > 0) { throw new global::System.Exception("Validation time is in future."); } ISet completeCrls = PkixCertPathValidatorUtilities.GetCompleteCrls(dp, attrCert, utcNow, paramsPKIX); bool flag = false; global::System.Exception ex = null; global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)completeCrls).GetEnumerator(); while (enumerator.MoveNext() && certStatus.Status == 11 && !reasonMask.IsAllReasons) { try { X509Crl x509Crl = (X509Crl)enumerator.get_Current(); ReasonsMask reasonsMask = Rfc3280CertPathUtilities.ProcessCrlD(x509Crl, dp); if (reasonsMask.HasNewReasons(reasonMask)) { ISet keys = Rfc3280CertPathUtilities.ProcessCrlF(x509Crl, attrCert, null, null, paramsPKIX, certPathCerts); AsymmetricKeyParameter key = Rfc3280CertPathUtilities.ProcessCrlG(x509Crl, keys); X509Crl x509Crl2 = null; if (paramsPKIX.IsUseDeltasEnabled) { ISet deltaCrls = PkixCertPathValidatorUtilities.GetDeltaCrls(utcNow, paramsPKIX, x509Crl); x509Crl2 = Rfc3280CertPathUtilities.ProcessCrlH(deltaCrls, key); } if (paramsPKIX.ValidityModel != 1 && attrCert.NotAfter.CompareTo((object)x509Crl.ThisUpdate) < 0) { throw new global::System.Exception("No valid CRL for current time found."); } Rfc3280CertPathUtilities.ProcessCrlB1(dp, attrCert, x509Crl); Rfc3280CertPathUtilities.ProcessCrlB2(dp, attrCert, x509Crl); Rfc3280CertPathUtilities.ProcessCrlC(x509Crl2, x509Crl, paramsPKIX); Rfc3280CertPathUtilities.ProcessCrlI(validDate, x509Crl2, attrCert, certStatus, paramsPKIX); Rfc3280CertPathUtilities.ProcessCrlJ(validDate, x509Crl, attrCert, certStatus); if (certStatus.Status == 8) { certStatus.Status = 11; } reasonMask.AddReasons(reasonsMask); flag = true; } } catch (global::System.Exception ex2) { ex = ex2; } } if (flag) { return; } throw ex; }
public static long DateTimeToUnixMs(global::System.DateTime dateTime) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (dateTime.CompareTo((object)UnixEpoch) < 0) { throw new ArgumentException("DateTime value may not be before the epoch", "dateTime"); } return((dateTime.get_Ticks() - UnixEpoch.get_Ticks()) / 10000); }
public virtual bool Match(object obj) { X509Crl x509Crl = obj as X509Crl; if (x509Crl == null) { return(false); } if (dateAndTime != null) { global::System.DateTime value = dateAndTime.Value; global::System.DateTime thisUpdate = x509Crl.ThisUpdate; DateTimeObject nextUpdate = x509Crl.NextUpdate; if (value.CompareTo((object)thisUpdate) < 0 || nextUpdate == null || value.CompareTo((object)nextUpdate.Value) >= 0) { return(false); } } if (issuers != null) { X509Name issuerDN = x509Crl.IssuerDN; bool flag = false; { global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)issuers).GetEnumerator(); try { while (enumerator.MoveNext()) { X509Name x509Name = (X509Name)enumerator.get_Current(); if (x509Name.Equivalent(issuerDN, inOrder: true)) { flag = true; break; } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } if (!flag) { return(false); } } if (maxCrlNumber != null || minCrlNumber != null) { Asn1OctetString extensionValue = x509Crl.GetExtensionValue(X509Extensions.CrlNumber); if (extensionValue == null) { return(false); } BigInteger positiveValue = DerInteger.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue)).PositiveValue; if (maxCrlNumber != null && positiveValue.CompareTo(maxCrlNumber) > 0) { return(false); } if (minCrlNumber != null && positiveValue.CompareTo(minCrlNumber) < 0) { return(false); } } DerInteger derInteger = null; try { Asn1OctetString extensionValue2 = x509Crl.GetExtensionValue(X509Extensions.DeltaCrlIndicator); if (extensionValue2 != null) { derInteger = DerInteger.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue2)); } } catch (global::System.Exception) { return(false); } if (derInteger == null) { if (DeltaCrlIndicatorEnabled) { return(false); } } else { if (CompleteCrlEnabled) { return(false); } if (maxBaseCrlNumber != null && derInteger.PositiveValue.CompareTo(maxBaseCrlNumber) > 0) { return(false); } } if (issuingDistributionPointEnabled) { Asn1OctetString extensionValue3 = x509Crl.GetExtensionValue(X509Extensions.IssuingDistributionPoint); if (issuingDistributionPoint == null) { if (extensionValue3 != null) { return(false); } } else if (!Arrays.AreEqual(extensionValue3.GetOctets(), issuingDistributionPoint)) { return(false); } } return(true); }
protected List <ILugusConfigProfile> _profiles = new List <ILugusConfigProfile>(); // All profiles registered in this configuration, incl. system profile. #endregion #if !UNITY_WEBPLAYER && !UNITY_IPHONE && !UNITY_ANDROID && !UNITY_WP8 // Reload all profiles found in the Config folder. public void ReloadDefaultProfiles() { _profiles = new List <ILugusConfigProfile>(); _systemProfile = null; _currentUser = null; // Load the profiles found in the config folder of the application datapath // and try to set the latest user as the current user. // If no profiles could be found in the folder, // then create a default system and user profile. string configpath = Application.dataPath + "/Config/"; if (!Directory.Exists(configpath)) { Debug.LogWarning("LugusConfigDefault: Config folder didn't exist yet. Creating it."); Directory.CreateDirectory(configpath); } DirectoryInfo directoryInfo = new DirectoryInfo(configpath); FileInfo[] files = directoryInfo.GetFiles("*.xml"); System.DateTime mostRecentUserSaveTime = new global::System.DateTime(2000, 01, 01); if (files.Length > 0) { // Create and load profiles foreach (FileInfo fileInfo in files) { string profileName = fileInfo.Name.Remove(fileInfo.Name.LastIndexOf(".xml")); LugusConfigProfileDefault profile = new LugusConfigProfileDefault(profileName); profile.Load(); if (profileName == "System") { _systemProfile = profile; Debug.Log("LugusConfigDefault: Found system profile."); } else { Debug.Log("LugusConfigDefault: Found user profile: " + profileName); // In most cases, the System config profile will contain a reference to the latest player profile (see below), which will override this. // However, in some rare cases (System file is missing or does not contain User.Latest, the system can default to the last saved non-system profile. // mostRecentUserSaveTime.CompareTo will return -1 if new value is more recent than itself. if (mostRecentUserSaveTime.CompareTo(fileInfo.LastWriteTime) < 0) { mostRecentUserSaveTime = fileInfo.LastWriteTime; _currentUser = profile; } } _profiles.Add(profile); } } // If the system profile wasn't found, create it. if (_systemProfile == null) { Debug.LogWarning("LugusConfigDefault: A system config profile was not found. Now creating one at runtime."); LugusConfigProfileDefault sysProfile = new LugusConfigProfileDefault("System"); this.System = sysProfile; _profiles.Add(sysProfile); } // Set current user to the one saved in system profile. string lastestUser = _systemProfile.GetString("User.Latest", string.Empty); if (!string.IsNullOrEmpty(lastestUser)) { ILugusConfigProfile playerProfile = _profiles.Find(profile => profile.Name == lastestUser); if (playerProfile != null) { _currentUser = playerProfile; } else if (_currentUser != null) { // If a player file was deleted, no file can be returned. In that case, default to _currentUser's default value of the latest save (see above). Debug.LogWarning("LugusConfigDefault: The system config profile's last user value referred to a file that doesn't exist anymore. Defaulting to latest saved file instead: " + _currentUser.Name + "."); // If we're defaulting to the latest save, might as well change the latest user in the system profile to a file that does exist. _systemProfile.SetString("User.Latest", _currentUser.Name, true); _systemProfile.Store(); } } // If the system profile did not have a value for latest user, but there are other profiles available, default to the latest save (see above). // Display a warning to make developers aware of this. else if (_currentUser != null) { Debug.LogWarning("LugusConfigDefault: The system config profile did not (yet) contain a value indicating the last user. Defaulting to latest saved file instead: " + _currentUser.Name + "."); // If we're defaulting to the latest save, might as well save that name from now on. _systemProfile.SetString("User.Latest", _currentUser.Name, true); _systemProfile.Store(); } // If a current user couldn't be found at all (either listed in the system profile or by defaulting to the latest saved profile), create a new one. if (_currentUser == null) { Debug.LogWarning("LugusConfigDefault: A latest user profile was not found. Now creating one named \"Player\"."); _currentUser = new LugusConfigProfileDefault("Player"); _profiles.Add(_currentUser); // If we're creating a new user profile, might as well save it to the system profile from now on. _systemProfile.SetString("User.Latest", "Player", true); _systemProfile.Store(); } }
public virtual bool Match(object obj) { X509Certificate x509Certificate = obj as X509Certificate; if (x509Certificate == null) { return(false); } if (!MatchExtension(authorityKeyIdentifier, x509Certificate, X509Extensions.AuthorityKeyIdentifier)) { return(false); } if (basicConstraints != -1) { int num = x509Certificate.GetBasicConstraints(); if (basicConstraints == -2) { if (num != -1) { return(false); } } else if (num < basicConstraints) { return(false); } } if (certificate != null && !certificate.Equals(x509Certificate)) { return(false); } if (certificateValid != null && !x509Certificate.IsValid(certificateValid.Value)) { return(false); } if (extendedKeyUsage != null) { global::System.Collections.IList list = x509Certificate.GetExtendedKeyUsage(); if (list != null) { { global::System.Collections.IEnumerator enumerator = ((global::System.Collections.IEnumerable)extendedKeyUsage).GetEnumerator(); try { while (enumerator.MoveNext()) { DerObjectIdentifier derObjectIdentifier = (DerObjectIdentifier)enumerator.get_Current(); if (!list.Contains((object)derObjectIdentifier.Id)) { return(false); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } } } } if (issuer != null && !issuer.Equivalent(x509Certificate.IssuerDN, inOrder: true)) { return(false); } if (keyUsage != null) { bool[] array = x509Certificate.GetKeyUsage(); if (array != null) { for (int i = 0; i < 9; i++) { if (keyUsage[i] && !array[i]) { return(false); } } } } if (policy != null) { Asn1OctetString extensionValue = x509Certificate.GetExtensionValue(X509Extensions.CertificatePolicies); if (extensionValue == null) { return(false); } Asn1Sequence instance = Asn1Sequence.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue)); if (((global::System.Collections.ICollection)policy).get_Count() < 1 && instance.Count < 1) { return(false); } bool flag = false; { global::System.Collections.IEnumerator enumerator = instance.GetEnumerator(); try { while (enumerator.MoveNext()) { PolicyInformation policyInformation = (PolicyInformation)enumerator.get_Current(); if (policy.Contains(policyInformation.PolicyIdentifier)) { flag = true; break; } } } finally { global::System.IDisposable disposable2 = enumerator as global::System.IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } } if (!flag) { return(false); } } if (privateKeyValid != null) { Asn1OctetString extensionValue2 = x509Certificate.GetExtensionValue(X509Extensions.PrivateKeyUsagePeriod); if (extensionValue2 == null) { return(false); } PrivateKeyUsagePeriod instance2 = PrivateKeyUsagePeriod.GetInstance(X509ExtensionUtilities.FromExtensionValue(extensionValue2)); global::System.DateTime value = privateKeyValid.Value; global::System.DateTime dateTime = instance2.NotAfter.ToDateTime(); global::System.DateTime dateTime2 = instance2.NotBefore.ToDateTime(); if (value.CompareTo((object)dateTime) > 0 || value.CompareTo((object)dateTime2) < 0) { return(false); } } if (serialNumber != null && !serialNumber.Equals(x509Certificate.SerialNumber)) { return(false); } if (subject != null && !subject.Equivalent(x509Certificate.SubjectDN, inOrder: true)) { return(false); } if (!MatchExtension(subjectKeyIdentifier, x509Certificate, X509Extensions.SubjectKeyIdentifier)) { return(false); } if (subjectPublicKey != null && !subjectPublicKey.Equals(GetSubjectPublicKey(x509Certificate))) { return(false); } if (subjectPublicKeyAlgID != null && !subjectPublicKeyAlgID.Equals(GetSubjectPublicKey(x509Certificate).AlgorithmID)) { return(false); } return(true); }