GetSubjectAlternativeNames() public method

public GetSubjectAlternativeNames ( ) : ICollection
return ICollection
Example #1
0
        private static byte[][] retrieveDnsNames(X509Certificate bouncyCertificate)
        {
            var           subjectAlternativeNames = bouncyCertificate.GetSubjectAlternativeNames();
            List <byte[]> dnsNameList             = new List <byte[]>();

            foreach (IList subjectAlternativeNameValueList in subjectAlternativeNames)
            {
                int    tag         = (int)subjectAlternativeNameValueList[0];
                string stringValue = (string)subjectAlternativeNameValueList[1];

                if (GeneralName.DnsName == tag)
                {
                    dnsNameList.Add(StringUtil.StringToByteArray(stringValue));
                }
            }

            return(dnsNameList.ToArray());
        }
        /// <summary>
        /// 
        /// </summary>
        private static bool CheckCertSubjectNames(X509Certificate cert) {
            bool found = false;
            ArrayList subjectNamesList = (ArrayList)cert.GetSubjectAlternativeNames();
            for (int i=0; i < subjectNamesList.Count; i++) {
                ArrayList subjectNames = (ArrayList)subjectNamesList[i];
                for (int j = 0; j < subjectNames.Count; j++) {
                    if (subjectNames[j] is String && subjectNames[j].Equals(Sdk.ECHO_API_DOMAIN_NAME)) {
                        found = true;
                        break;
                    }
                }
            }

            return found;
        }