# OpenSSL configuration file to create a server certificate
# by Michal Trojnara 1998-2019

####################################################################
[ ca ]
default_ca	= CA_default		# The default ca section

####################################################################
[ CA_default ]
# Directory and file locations.
dir		= C:/CA			# Where everything is kept
certs		= $dir/certs		# Where the issued certs are kept
crl_dir		= $dir/crl		# Where the issued crl are kept
database	= $dir/index.txt	# database index file.
#unique_subject	= no			# Set to 'no' to allow creation of
# several ctificates with same subject.
new_certs_dir	= $dir/newcerts		# default place for new certs.

serial		= $dir/serial 		# The current serial number
RANDFILE	= $dir/private/.rand	# private random number file



# The root key and root certificate
certificate	= $dir/cacert.pem 	# The CA certificate
private_key	= $dir/private/cakey.pem# The private key



# For certificate revocation lists.
crlnumber	= $dir/crlnumber	# the current crl number
crl		= $dir/crl.pem 		# The current CRL
					# must be commented out to leave a V1 CRL
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions	= crl_ext
default_crl_days= 30			# how long before next CRL
default_days	= 365			# how long to certify for


# Extension to add when the -x509 option is used.
#x509_extensions	= usr_cert		# The extentions to add to the cert
# Extension copying option: use with caution.
# copy_extensions = copy


# SHA-1 is deprecated, so use SHA-2 instead.
default_md	= default		# use public key default MD
preserve	= no			# keep passed DN ordering
# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt 	= ca_default		# Subject Name options
cert_opt 	= ca_default		# Certificate field options


# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy		= policy_match

# For the CA policy
[ policy_match ]
countryName		= match
stateOrProvinceName	= match
organizationName	= match
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional

# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName		= match
stateOrProvinceName	= supplied
localityName		= supplied
organizationName	= supplied
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional

####################################################################
[ req ]
# comment out the next line to protect the private key with a passphrase
encrypt_key                     = no
# the default key length is secure and quite fast - do not change it
default_bits                    = 2048
default_md                      = sha256
x509_extensions                 = stunnel_extensions
distinguished_name              = stunnel_dn
prompt                          = yes

[ stunnel_extensions ]
nsCertType                      = server
basicConstraints                = CA:TRUE,pathlen:0
keyUsage                        = keyCertSign
extendedKeyUsage                = serverAuth
nsComment                       = "stunnel self-signed certificate"

[ stunnel_dn ]
countryName = Country Name (2 letter code)
countryName_default             = MY
countryName_min                 = 2
countryName_max                 = 2

stateOrProvinceName             = State or Province Name (full name)
stateOrProvinceName_default     = Selangor

localityName                    = Locality Name (eg, city)
localityName_default            = Cyberjaya

organizationName                = Organization Name (eg, company)
organizationName_default        = EntryPass

organizationalUnitName          = Organizational Unit Name (eg, section)
organizationalUnitName_default  = RND

0.commonName                    = Common Name (FQDN of your server)
0.commonName_default            = EP

1.commonName                  = EP1
2.commonName                  = EP2

# To create a certificate for more than one name uncomment:
# 1.commonName                  = DNS alias of your server
# 2.commonName                  = DNS alias of your server
# ...
# See http://home.netscape.com/eng/security/ssl_2.0_certificate.html
# to see how Netscape understands commonName.


[ usr_cert ]
# Extensions for client certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = client, email
nsComment = "OpenSSL Generated Client Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth, emailProtection
