From 421687c4c32e893b380c9fe40f34ae9b38a824fb Mon Sep 17 00:00:00 2001
From: Lesterpig <git@lesterpig.com>
Date: Thu, 3 Dec 2015 10:48:19 +0100
Subject: [PATCH] [auth] Add example for x509.Verify

---
 auth/cert_test.go | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/auth/cert_test.go b/auth/cert_test.go
index 68888c2..2ffd0e3 100644
--- a/auth/cert_test.go
+++ b/auth/cert_test.go
@@ -2,6 +2,7 @@ package auth
 
 import (
 	"crypto/rsa"
+	"crypto/x509"
 	"fmt"
 	"os"
 	"testing"
@@ -151,10 +152,28 @@ func ExampleGetCertificate() {
 	if cert == nil || err != nil {
 		fmt.Println(err)
 	} else {
-		fmt.Println("OK")
+		fmt.Println("Certificate generated")
+	}
+
+	// Check certificate validity
+
+	roots := x509.NewCertPool()
+	roots.AddCert(signerCertificate)
+
+	signeeCertificate, _ := PEMToCertificate(cert)
+
+	_, err = signeeCertificate.Verify(x509.VerifyOptions{
+		Roots: roots,
+	})
+
+	if err != nil {
+		fmt.Println(err)
+	} else {
+		fmt.Println("Certificate authenticated")
 	}
 
 	// Output:
-	// OK
+	// Certificate generated
+	// Certificate authenticated
 
 }
-- 
GitLab