webid

package module
v0.0.0-...-d86f8f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2013 License: BSD-3-Clause Imports: 11 Imported by: 0

README

WebID for GO

A basic library to validate a WebID. The only function so far is

webid.Validate(tls *tls.ConnectionState)

which should be called in the handler function. It returns

(*id, err)

with the subjectAltName in id.Name and result of the validation in id.Valid.

Example

package main

import (
	"crypto/tls"
	"fmt"
	"log"
	"net/http"
	"webid"
)

func handler(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Content-Type", "text/plain")

	id, err := webid.Validate(req.TLS)
	if err != nil {
		w.Write([]byte(fmt.Sprintln(err)))
	} else {
		w.Write([]byte(fmt.Sprintln(id.Name, "is valid?", id.Valid)))
	}
}

func main() {
	http.HandleFunc("/", handler)
	log.Printf("About to listen on 10443. Go to https://127.0.0.1:10443/")
	server := &http.Server{Addr: ":10443"}
	server.TLSConfig = &tls.Config{ClientAuth: tls.RequestClientCert}
	err := server.ListenAndServeTLS("https/keys/cert.pem", "https/keys/key.pem")
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(tls *tls.ConnectionState) (*id, error)

Types

type PublicKeyAlgorithm

type PublicKeyAlgorithm int
const (
	UnknownPublicKeyAlgorithm PublicKeyAlgorithm = iota
	RSA
	DSA
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL