Git Product home page Git Product logo

contract_x509's Introduction

x509-forest-of-trust

Solidity contract that parses and verifies X.509 certificate chains and stores them in parent pointer trees on the ETH blockchain. An ETH account can then prove ownership of a verified certificate in the tree.

Useful for:

  1. associating a domain with an Ethereum address: dns-over-ens
  2. verifying HTTP responses on-chain using Signed HTTP Exchanges (SXG) / web packages

The easiest way to use this contract from within your web3 app is via the javascript API:

const CertificateUploader = require('x509-forest-of-trust')
const fs = require('fs')
const pemCertRoot =         fs.readFileSync(__dirname + '/certs/root.pem')
const pemCertIntermediate = fs.readFileSync(__dirname + '/certs/intermediate.pem')
const pemCertLeaf =         fs.readFileSync(__dirname + '/certs/leaf.pem')
const pemCertLeafPkcs8Key = fs.readFileSync(__dirname + '/certs/leafPkcs8Key.pem')

// Inject web3 instance into javascript API
const api = CertificateUploader(web3, { chainId: 1 })

const pemCertChain = [pemCertRoot, pemCertIntermediate, pemCertLeaf]
const from = web3.eth.defaultAccount // or any address that's in web3.eth.accounts
api.addCertAndProveOwnership(from, pemCertChain, pemCertLeafPkcs8Key)
.then(() => {
  console.log('Certificates have been parsed, verified, and saved to the blockchain.')
  console.log(from + ' has been set as the owner of the leaf (aka end-entity) certificate.')
})
.catch(console.error)

note: contracts must be redeployed between tests

contract_x509's People

Contributors

cryptoninja0331 avatar

Stargazers

 avatar

Watchers

 avatar

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.