self-signed certificates
Hiển thị các bài đăng có nhãn self-signed certificates. Hiển thị tất cả bài đăng

Bash script to generate a self signed certificate

  Bash Script Create Self-Signed Certificates Using OpenSSL


#!/bin/bash

# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Large portions of this script were taken from the
# following artcile:
# 
# http://usrportage.de/archives/919-Batch-generating-SSL-certificates.html
# 
# Additional alterations by: Brad Landers
# Date: 2012-01-27
# usage: ./gen_cert.sh example.com

# Script accepts a single argument, the fqdn for the cert
DOMAIN="$1"
if [ -z "$DOMAIN" ]; then
  echo "Usage: $(basename $0) "
  exit 11
fi

fail_if_error() {
  [ $1 != 0 ] && {
    unset PASSPHRASE
    exit 10
  }
}

# Generate a passphrase
export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo)

# Certificate details; replace items in angle brackets with your own info
subj="
C=US
ST=OR
O=Blah
localityName=Portland
commonName=$DOMAIN
organizationalUnitName=Blah Blah
emailAddress=admin@example.com
"

# Generate the server private key
openssl genrsa -des3 -out $DOMAIN.key -passout env:PASSPHRASE 2048
fail_if_error $?

# Generate the CSR
openssl req \
    -new \
    -batch \
    -subj "$(echo -n "$subj" | tr "\n" "/")" \
    -key $DOMAIN.key \
    -out $DOMAIN.csr \
    -passin env:PASSPHRASE
fail_if_error $?
cp $DOMAIN.key $DOMAIN.key.org
fail_if_error $?

# Strip the password so we don't have to type it every time we restart Apache
openssl rsa -in $DOMAIN.key.org -out $DOMAIN.key -passin env:PASSPHRASE
fail_if_error $?

# Generate the cert (good for 10 years)
openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt
fail_if_error $?

Source: gist


Cấu hình Hyper-V replica with self-signed certificates

Hyper-V Replica with self-signed certificates


Yêu cầu thực tế:
Có 02 Hyper-V server (workgroup):
  • O365-HOST01-SVR
  • O365-HOST02-SVR
Cấu hình replica cho 02 máy chủ Hyper-V

Phân tích:
Việc replica giữa các Hyper-V server có thể thực hiện qua http (80) hoặc https (443).
Đối với https thì cần có certicate chứng thực giữa các server.

Search google một vòng thì có khá nhiều bài viết hướng dẫn replicate (http hoặc https),  tạo self-signed certificates sử dụng công cụ MakeCert hoặc Powershell.

Tôi đã thử và....không thành công. :(

Ở  bài viết này, tôi chia sẻ cách làm thành công của bản thân bằng Powershell
Về Powershell thì có khác biệt khá lớn giữa Powershell 4.0 và Powershell 5.0