This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"crypto/x509" | |
"flag" | |
"io" | |
"io/ioutil" | |
"log" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/x509" | |
"crypto/x509/pkix" | |
"encoding/asn1" | |
"encoding/pem" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// createCertificateAuthority generates a certificate authority request ready to be signed | |
// | |
func (r *secretStore) createCertificateAuthority(names pkix.Name, expiration time.Duration, size int) (*caCertificate, error) { | |
// step: generate a keypair | |
keys, err := rsa.GenerateKey(rand.Reader, size) | |
if err != nil { | |
return nil, fmt.Errorf("unable to genarate private keys, error: %s", err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2009 The Go Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
// +build ignore | |
// Generate a self-signed X.509 certificate for a TLS server. Outputs to | |
// 'cert.pem' and 'key.pem' and will overwrite existing files. | |
package main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
// Name of the struct tag used in examples | |
const tagName = "validate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
fmt.Println(Bitmask(0x6).IsSet(0x2)) | |
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListDescriptions(charValues)) | |
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListValues(charValues)) | |
*/ | |
type Bitmask uint16 | |
// BitValue is a value and a description | |
type BitValue struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Genarate rsa keys. | |
*/ | |
package main | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/x509" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LANG=en_US.utf-8 | |
LC_ALL=en_US.utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Writes an APR1-format password hash to the provided <htpasswd-file> for a provided <username> | |
# This is useful where an alternative web server (e.g. nginx) supports APR1 but no `htpasswd` is installed. | |
# The APR1 format provides signifcantly stronger password validation, and is described here: | |
# http://httpd.apache.org/docs/current/misc/password_encryptions.html | |
help (){ | |
cat <<EOF | |
Usage: $0 <htpasswd-file> <username> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export VPN_NAME="my_private_vpn" | |
export MY_NAME="raspi" | |
export VPN_IP="172.16.1.2" # change this to be different for each node | |
export CONNECTION="LAN" # is this server connected to a "WAN" or "LAN" | |
export TINC_PORT="655" | |
export AUTO_TRUE="YES" |
NewerOlder