private static bool GetBundleInfo(byte[] unsignedBundleBytes, out SslSocket.BundleInfo info) { info.bundleKeyHashs = new List <byte[]>(); info.bundleUris = new List <string>(); info.bundleCerts = new List <X509Certificate2>(); string text = null; string @string = Encoding.ASCII.GetString(unsignedBundleBytes); try { JsonNode jsonNode = Json.Deserialize(@string) as JsonNode; JsonList jsonList = jsonNode["PublicKeys"] as JsonList; foreach (object obj in jsonList) { JsonNode jsonNode2 = (JsonNode)obj; string item = (string)jsonNode2["Uri"]; string hex = (string)jsonNode2["ShaHashPublicKeyInfo"]; byte[] item2 = null; SslSocket.HexStrToBytesError hexStrToBytesError = SslSocket.HexStrToBytes(hex, out item2); if (hexStrToBytesError != SslSocket.HexStrToBytesError.OK) { text = EnumUtils.GetString <SslSocket.HexStrToBytesError>(hexStrToBytesError); break; } info.bundleKeyHashs.Add(item2); info.bundleUris.Add(item); } JsonList jsonList2 = jsonNode["SigningCertificates"] as JsonList; foreach (object obj2 in jsonList2) { JsonNode jsonNode3 = (JsonNode)obj2; string s = (string)jsonNode3["RawData"]; byte[] bytes = Encoding.ASCII.GetBytes(s); X509Certificate2 item3 = new X509Certificate2(bytes); info.bundleCerts.Add(item3); } } catch (Exception ex) { text = ex.ToString(); } if (text != null) { SslSocket.s_log.LogWarning("Exception while trying to parse certificate bundle. {0}", new object[] { text }); return(false); } return(true); }
private static bool GetBundleInfo(byte[] unsignedBundleBytes, out SslSocket.BundleInfo info) { info = new SslSocket.BundleInfo(); info.bundleKeyHashs = new List <byte[]>(); info.bundleUris = new List <string>(); info.bundleCerts = new List <X509Certificate2>(); string str = null; string str1 = Encoding.ASCII.GetString(unsignedBundleBytes); try { JsonNode jsonNode = Json.Deserialize(str1) as JsonNode; foreach (JsonNode item in jsonNode["PublicKeys"] as JsonList) { string item1 = (string)item["Uri"]; string item2 = (string)item["ShaHashPublicKeyInfo"]; byte[] numArray = null; SslSocket.HexStrToBytesError bytes = SslSocket.HexStrToBytes(item2, out numArray); if (bytes == SslSocket.HexStrToBytesError.OK) { info.bundleKeyHashs.Add(numArray); info.bundleUris.Add(item1); } else { str = EnumUtils.GetString <SslSocket.HexStrToBytesError>(bytes); break; } } foreach (JsonNode jsonNode1 in jsonNode["SigningCertificates"] as JsonList) { string str2 = (string)jsonNode1["RawData"]; X509Certificate2 x509Certificate2 = new X509Certificate2(Encoding.ASCII.GetBytes(str2)); info.bundleCerts.Add(x509Certificate2); } } catch (Exception exception) { str = exception.ToString(); } if (str == null) { return(true); } SslSocket.s_log.LogWarning("Exception while trying to parse certificate bundle. {0}", new object[] { str }); return(false); }