This repository contains the prototype Hammurabi engine. The engine is responsible for parsing certificates, emitting Prolog facts, aggregating those facts with rules, and executing additional policies to determine certificate validity.
It's designed almost entirely (as of now) for testing chrome.pl and firefox.pl, which are Prolog implementations of Chrome and Firefox's TLS certificate validation logic, respectively.
The easiest way to get started is to use the Vagrant box. To do so, you'll need
VirtualBox installed. In this directory, you can then run vagrant up
, then
vagrant ssh
. vagrant up
creates a new virtual machine, installs necessary
dependencies, vagrant ssh
connects to the box. After connecting to the Vagrant
box, run cargo build
to build everything. Then, run make
in the prolog
directory to build policy executables.
Note that vagrant up
might take a few minutes.
If on a Debian-based system, you can run scripts/install-dependencies.sh
to
install the necessary dependencies. Note that this will attempt to install
Rust---I recommend looking at that file before running it. If not on Debian,
you'll need to look at that file and install the analogous dependencies. Run
cargo build
after installing dependencies. Then, run make
in the prolog
directory to build policy executables.
Consider the certificate chain in
certs/141c7a18a5a00ef35ef43f89288f80405b358ea407c2deee933fa7d07a52559f.pem
.
You can execute the Chrome verification logic on this chain like so:
./target/debug/single chrome certs/141c7a18a5a00ef35ef43f89288f80405b358ea407c2deee933fa7d07a52559f.pem hrm.auth.gr
. hrm.auth.gr
is the domain you're validating against.
OK
means the constraints were satisfied, an error means they were not.
After running, you can examine prolog/job/certs.pl
to examine the facts
you can operate over. You can also look at the other facts and rules in
prolog/job/*
(for instance prolog/job/std.pl
contains some
convenience rules).
NOTE: we hardcode the current time as Friday, October 2, 2020 1:53:44 AM GMT.
Look at prolog/std.pl
, isTimeValid
. The above certificate is currently
expired, but is valid if you consider today's date Oct 2 :). You can change the
Unix timestamp in std.pl
if you want to check current certificates.
For now, the Cert
in verifiedChain(Cert)
is the leaf certificate. You can also
operate over the parent of the leaf---to see an example of this (and other
complex rules) look at Prolog Firefox and Chrome at prolog/static/firefox.pl
and prolog/static/chrome.pl
respectively.
To validate a certificate through Prolog Firefox, call `target/debug/single