/* * Add certificate to output. The caller is responsible for * opening the certificate object. */ void PrintCert(JSON js, X509Chain xchain, int num) { js.AddPair("thumbprint", xchain.ThumbprintsRev[num]); X509Cert xc = xchain.ElementsRev[num]; js.AddPair("decodable", xc != null); if (xc == null) { js.AddPair("decodeError", xchain.DecodingIssuesRev[num]); } else { js.AddPair("serialHex", xc.SerialHex); js.AddPair("subject", xc.Subject.ToString()); js.AddPair("issuer", xc.Issuer.ToString()); js.AddPair("validFrom", string.Format( "{0:yyyy-MM-dd HH:mm:ss} UTC", xc.ValidFrom)); js.AddPair("validTo", string.Format( "{0:yyyy-MM-dd HH:mm:ss} UTC", xc.ValidTo)); js.AddPair("keyType", xc.KeyType); js.AddPair("keySize", xc.KeySize); string cname = xc.CurveName; if (cname != null) { js.AddPair("keyCurve", cname); } js.AddPair("signHash", xc.HashAlgorithm); js.AddPair("selfIssued", xc.SelfIssued); if (num == 0) { js.OpenPairArray("serverNames"); foreach (string name in xc.ServerNames) { js.AddElement(name); } js.Close(); } } if (withPEM) { js.AddPair("PEM", M.ToPEM("CERTIFICATE", xchain.EncodedRev[num])); } }
/* * Encode the report as JSON. */ internal void Print(JSON js) { js.OpenInit(false); js.AddPair("connectionName", connName); js.AddPair("connectionPort", connPort); js.AddPair("SNI", sni); if (ssl2Suites != null && ssl2Suites.Length > 0) { js.OpenPairObject("SSLv2"); js.OpenPairArray("suites"); foreach (int s in ssl2Suites) { js.OpenElementObject(); js.AddPair("id", s); js.AddPair("name", CipherSuite.ToNameV2(s)); js.Close(); } js.Close(); js.Close(); } foreach (int v in suites.Keys) { js.OpenPairObject(M.VersionString(v)); SupportedCipherSuites scs = suites[v]; string sel; if (scs.PrefClient) { sel = "client"; } else if (scs.PrefServer) { sel = "server"; } else { sel = "complex"; } js.AddPair("suiteSelection", sel); js.OpenPairArray("suites"); foreach (int s in scs.Suites) { js.OpenElementObject(); js.AddPair("id", s); js.AddPair("name", CipherSuite.ToName(s)); CipherSuite cs; if (CipherSuite.ALL.TryGetValue(s, out cs)) { js.AddPair("strength", cs.Strength); js.AddPair("forwardSecrecy", cs.HasForwardSecrecy); js.AddPair("anonymous", cs.IsAnonymous); js.AddPair("serverKeyType", cs.ServerKeyType); } js.Close(); } js.Close(); js.Close(); } if (ssl2Chain != null) { js.OpenPairObject("ssl2Cert"); PrintCert(js, ssl2Chain, 0); js.Close(); } js.OpenPairArray("ssl3Chains"); foreach (X509Chain xchain in chains.Values) { js.OpenElementObject(); int n = xchain.Elements.Length; js.AddPair("length", n); js.AddPair("decoded", xchain.Decodable); if (xchain.Decodable) { js.AddPair("namesMatch", xchain.NamesMatch); js.AddPair("includesRoot", xchain.IncludesRoot); js.OpenPairArray("signHashes"); foreach (string name in xchain.SignHashes) { js.AddElement(name); } js.Close(); } js.OpenPairArray("certificates"); for (int i = 0; i < n; i++) { js.OpenElementObject(); PrintCert(js, xchain, i); js.Close(); } js.Close(); js.Close(); } js.Close(); js.AddPair("deflateCompress", DeflateCompress); if (serverTimeOffset == Int64.MinValue) { js.AddPair("serverTime", "none"); } else if (serverTimeOffset == Int64.MaxValue) { js.AddPair("serverTime", "random"); } else { DateTime dt = DateTime.UtcNow; dt = dt.AddMilliseconds((double)serverTimeOffset); js.AddPair("serverTime", string.Format( "{0:yyyy-MM-dd HH:mm:ss} UTC", dt)); js.AddPair("serverTimeOffsetMillis", serverTimeOffset); } js.AddPair("secureRenegotiation", doesRenego); js.AddPair("rfc7366EtM", doesEtM); js.AddPair("ssl2HelloFormat", helloV2); if (minDHSize > 0) { js.AddPair("minDHSize", minDHSize); js.AddPair("kxReuseDH", kxReuseDH); } if (minECSize > 0) { js.AddPair("minECSize", minECSize); } if (minECSizeExt > 0) { js.AddPair("minECSizeExt", minECSizeExt); } if (minECSize > 0 || minECSizeExt > 0) { js.AddPair("kxReuseECDH", kxReuseECDH); } if ((namedCurves != null && namedCurves.Length > 0) || curveExplicitPrime > 0 || curveExplicitChar2 > 0) { js.OpenPairArray("namedCurves"); foreach (SSLCurve nc in namedCurves) { js.OpenElementObject(); js.AddPair("name", nc.Name); js.AddPair("size", nc.Size); js.AddPair("spontaneous", IsSpontaneous(nc)); js.Close(); } if (curveExplicitPrime > 0) { js.OpenElementObject(); js.AddPair("name", "explicitPrime"); js.AddPair("size", curveExplicitPrime); js.Close(); } if (curveExplicitChar2 > 0) { js.OpenElementObject(); js.AddPair("name", "explicitChar2"); js.AddPair("size", curveExplicitChar2); js.Close(); } js.Close(); } if (warnings == null) { Analyse(); } js.OpenPairArray("warnings"); foreach (string k in warnings.Keys) { js.OpenElementObject(); js.AddPair("id", k); js.AddPair("text", warnings[k]); js.Close(); } js.Close(); js.Close(); }