Code Monkey home page Code Monkey logo

certwatch_db's Introduction

certwatch_db

Database schema

certwatch_db's People

Contributors

alex avatar konklone avatar marksteward avatar robstradling avatar titanous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

certwatch_db's Issues

How often do you read the CCADB in?

I'm wondering, how often do you update the information in crt.sh with the information in CCADB? I did some queries in crt.sh on the information coming from CCADB and it turned out, that the completeness of the data is not very satisfying. Now I'm wondering, if the data is not in CCADB (which I can't access) or if there is a problem in the import of CCADB data.

Create index on ct_log_entry to improve speed

To increase the speed of a search for the first time a certificate showed up in any CT log, it would be (hopefully) helpful to have an additional index:

CREATE INDEX ctle_et_ci ON ct_log_entry (ENTRY_TIMESTAMP, CERTIFICATE_ID);

Could you please add this? Honestly I have to admit, I'm not 100% sure it will help, but I'm running out of ideas how to speed up my query otherwise.

SCT timestamps 1hr fast

Since deploying the new ct_monitor application (a few weeks ago) until just now, SCT timestamps were recorded on the crt.sh database 1hr fast.

The problem was that ct_monitor was assuming that the TimestampToTime() function in github.com/google/certificate-transparency-go was returning timestamps in UTC, when in fact they were in local time. Local time on the crt.sh servers is BST (i.e., GMT+1).

I just fixed ct_monitor (by adding an explicit conversion to UTC). This ticket is to track the additional task of fixing all of the (1hr fast) SCT timestamps on the database.

Host match search type

Add a "?host=" search type that will list certs with any identity that a browser would match to a URL on the host indicated by the search value.

e.g. ?host=www.example.com would match [CN or dNSName]=www.example.com, [CN or dNSName]=*.example.com, but not [CN or dNSName]=secure.example.com, etc.

Connection drops / time outs observed.

I'm developing a little tool (https://github.com/RufusJWB/crt.sh-monitor) to monitor the presence of our CA (https://crt.sh/?caid=52410 and possibly every other) at crt.sh. While implementing it, I have observed various time outs and connection drops. I'm wondering if my query kills the performance of your DB. If you want, you can use the tool under https://eo0kjkxapi.execute-api.eu-central-1.amazonaws.com/prod/crtsh-monitor?caID=52410&excludeExpired=true&onlyLINTErrors=true&excludeRevoked=true&verbose=true to check it.

Certificate Summary

[Suggested by @gerv]

On each certificate page, kick off with the key information in a summary line.
Some examples:

  • Cert for www.example.com and other names, issued by "CA ABC", valid now and until YYYY-MM-DD, not revoked by anyone.
  • Root cert "CA XYZ", not valid until YYYY-MM-DD, revoked by CA, Google and Microsoft.

Add a method for showing a certificate chain

https://crt.sh/?chain=<crtshID1>,<crtshID2>,etc

Show whether or not each crt.sh ID in the comma-separated list is a valid (or valid-but-expired, or invalid) issuer certificate for the preceding certificate in the list.

Unsupported output type when submitting certificate

It appears I'm hitting this when trying to submit a certificate generated using the certificate submission assistant. The curl POST seemed to work fine when using https://ct.googleapis.com/pilot/ct/v1/add-chain.

$ curl -X POST https://crt.sh/ct/v1/add-chain --data-binary "@add-chain-1c32fa4eb6430ee7e31551068a70b3c169c17294df923d9a4c0b943bbc2bab32.json"
<BR><BR>Unsupported output type: ct/v1/add-chain</BODY>
</HTML>

Filter by notBefore and/or notAfter date range

Add some new parameters that will filter the results based on the notBefore and notAfter dates in the certificate:
minNotBefore
maxNotBefore
minNotAfter
maxNotAfter

minNotBefore already exists for some searches (just the linting stuff, IIRC).

Add "notBefore range" and "notAfter range" to "Select search options:" on https://crt.sh/?a=1

Filter by Mozilla Owner

For compliance purposes, it would be very handy to be able to filter all of a CA Owner's CAs based on the "Mozilla Owner" field (i.e. the way that the CCADB tracks CA compliance). For instance, Digicert acquired some Cybertrust CAs from Verizon, so the Issuer "O" field is not as useful for obtaining a comprehensive snapshot. If I could see all of them on one screen, then it would be easier for me to remediate issues with external Sub CAs that issue non-compliant certificates.

Performance question

For science and fun I am trying to run crt.sh on my own hardware however it looks like I am running against some bottlenecks regarding performance. I am wondering if I am missing something. It looks like most time is spent inside the import_ct_cert function (obviously 🤣 ) however trying to find out which query inside (or insede import_cert) might be hauling this amount of rows has not been acomplished yet (which looks to be the biggest bottleneck).

screen shot 2017-08-09 at 00 40 51

When I started with an empty database (right now I have about 60M certs imported) it went a lot faster and was mostly bottlenecked by disk I/O however now it looks like to be CPU (the import query hogging a Postgres thread).

I was wondering if you have any idea why this is happening and what I could do to optimize since right now the google log is growing faster then I can import.

Also wondering what kind of hardware / setup crt.sh is using (figured a 4 SSD RAID10 with plenty of cores and ram would do the trick easily) 👀

Add a "Submit a certificate" page

When a user pastes a PEM-encoded cert and clicks a button, automatically construct the JSON for the /ct/v1/add-chain calls for whichever logs might accept the cert. Then let the page provide a Submit button for each applicable log. Use AJAX to submit the chain from the webpage.

Create a certificate lifecycle view

To simplify the search for unrevokes, unexpired certificates of a specific CA (e.g. to find all certificates with weak Debian keys that are not revoked nor expired) I would like to propose the creation of a view, that encapsulates the search for some typical lifecycle data of a certificate:

create view CERTIFICATE_LIFECYCLE as
select 
             C.ID CERTIFICATE_ID,
             C.ISSUER_CA_ID CA_ID,
             encode(X509_SERIALNUMBER(C.CERTIFICATE), 'hex') SERIAL_NUMBER,
             X509_SUBJECTNAME(C.CERTIFICATE) SUBJECT_DISTINGUISHED_NAME,
             (CASE WHEN (x509_print(C.CERTIFICATE) LIKE '%CT Precertificate Poison%') THEN
                 'Precertificate'
             ELSE
                 'Certificate'
             END) CERTIFICATE_TYPE,
             X509_NOTBEFORE(C.CERTIFICATE) NOT_BEFORE,
             X509_NOTAFTER(C.CERTIFICATE) NOT_AFTER,
             CTLE.FIRST_SEEN FIRST_SEEN,
             COALESCE(CRL.REVOKED, 0) REVOKED,
             COALESCE(LCI.LINT_ERRORS, 0) LINT_ERRORS,
             X509_NOTAFTER(C.CERTIFICATE) < now() EXPIRED
     from CERTIFICATE C
     join lateral
         (select MIN(CTLE.ENTRY_TIMESTAMP) FIRST_SEEN,
                 CTLE.CERTIFICATE_ID
          from CT_LOG_ENTRY CTLE
          where CTLE.CERTIFICATE_ID = C.ID
          group by CTLE.CERTIFICATE_ID) CTLE on true
     left join lateral
         (select COUNT(CRL.CA_ID) REVOKED,
                 CRL.SERIAL_NUMBER
          from CRL_REVOKED CRL
          where CRL.CA_ID = C.ISSUER_CA_ID
              and CRL.SERIAL_NUMBER = X509_SERIALNUMBER(C.CERTIFICATE)
          group by CRL.SERIAL_NUMBER) CRL on true
     left join lateral
         (select COUNT(LCI.CERTIFICATE_ID) LINT_ERRORS,
                 LCI.CERTIFICATE_ID
          from LINT_CERT_ISSUE LCI
          where LCI.CERTIFICATE_ID = C.ID
          group by LCI.CERTIFICATE_ID) LCI on true

Add 'Upload' to https://crt.sh/lintcert

It'd be nice if there were an "Upload" button on the lintcert HTML form.

Sample code e.g. https://twitter.com/ericlaw/status/916342499790204930

<script> function handleFiles() { var reader = new FileReader(); reader.onload = function(e) { var str = reader.result; if (str.startsWith("-----BEGIN CERTIFICATE-----")) { str = str.slice(28); let ixLastDash = str.indexOf("-"); if (ixLastDash>0) str = str.slice(0,ixLastDash); } document.getElementById("b64cert").innerText = str; } reader.readAsText(document.getElementById("fil").files[0]); } </script> crt.sh Certificate Linter

1. Enter a base64 encoded Certificate or pick a file:

2. Press the "Lint Certificate" button.

<TEXTAREA name="b64cert" id="b64cert" rows=25 cols=64></TEXTAREA>

There is no parameter $3

When trying to view https://crt.sh/?cablint=226&iCAID=1687, I receive the following:

For certificates with notBefore >= 2016-02-02:

There is no parameter $3

PL/pgSQL function web_apis(text,text[],text[]) line 1347 at EXECUTE statement

SELECT c.ID, x509_subjectName(c.CERTIFICATE) SUBJECT_NAME, x509_notBefore(c.CERTIFICATE) NOT_BEFORE, x509_notAfter(c.CERTIFICATE) NOT_AFTER FROM certificate c , cablint_cert_issue cci WHERE c.ISSUER_CA_ID = $1::integer AND c.ID = cci.CERTIFICATE_ID AND cci.ISSUER_CA_ID = $1::integer AND cci.NOT_BEFORE >= $3 AND cci.CABLINT_ISSUE_ID = $2::integer GROUP BY c.ID, SUBJECT_NAME, NOT_BEFORE, NOT_AFTER ORDER BY NOT_BEFORE DESC OFFSET 0 LIMIT 100

It looks like the notBefore is not associating with the correct variable/parameter (?)

Return HTTP 404 on requests for non-existent certificates

Example:

~ ❯❯❯ http head 'https://crt.sh/?sha256=BB146B5C18893D4AE14356BC2ED2AA78EB6E162D9DE2520AA4F9DA97FE06B0AA'
HTTP/1.1 200 OK
Cache-Control: max-age=300
Connection: Keep-Alive
Content-Length: 3025
Content-Type: text/html; charset=UTF-8
Date: Wed, 10 May 2017 21:42:09 GMT
Expect-CT: preload
Keep-Alive: timeout=15, max=100
Server: Apache
Strict-Transport-Security: max-age=15768000; includeSubDomains; preload

that ought to be a 404, since there's no certificate at that URL

Replace integer by bigint

Due to range of accepted values it might be worth replacing

  • integer -> bigint
  • serial -> bigserial

for record ID and foreigh indices as documented in the PostgreSQL manual.

Given we currently handle about 100-200 million certificates, this might soon reach the constraints imposed by the smaller int32-based data types.

Make OCSP responder test queries identifiable

It would be great, if you could make the OCSP responder test queries for unknown certificates somehow identifiable, e.g. by letting the random serial number always start with '0f0f0f'. The background for this request is, that our OCSP monitoring always sends an alert when a request for an unknown certificate have been logged. This logging can't be easily filtered for the IP address of the requesting address and would need always manual digging in other log files. If you would embed such a magic string in the serial number, we could easily filter for them.

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.