Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
679cc560
Kaydet (Commit)
679cc560
authored
Ock 05, 2016
tarafından
Miklos Vajna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
xmlsecurity: add script to create test certificates
Change-Id: I9280cec602e15e3ae478911360ff7ce68d460474
üst
627c2469
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
428 additions
and
0 deletions
+428
-0
create-certs.sh
xmlsecurity/qa/create-certs/create-certs.sh
+164
-0
intermediate.cnf
xmlsecurity/qa/create-certs/templates/intermediate.cnf
+132
-0
root.cnf
xmlsecurity/qa/create-certs/templates/root.cnf
+132
-0
No files found.
xmlsecurity/qa/create-certs/create-certs.sh
0 → 100755
Dosyayı görüntüle @
679cc560
#!/bin/bash -e
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# The purpose of this script is to create certificates to be able to test ODF signing code.
#
# What it does:
#
# 1) Create a test root CA.
#
# 2) Create an intermediate CA, as signing certificates with a root CA is
# considered unsafe.
#
# 3) Create two client certificates that can be used to sign ODF documents in
# LibreOffice.
#
# References:
#
# <https://jamielinux.com/docs/openssl-certificate-authority/> for most of the
# commands.
#
# <https://www.sslshopper.com/article-most-common-openssl-commands.html> for
# the PKCS#12 export of self-signed certificates
#
root
=
"
$PWD
"
if
[
-d
"
$root
/ca"
]
;
then
echo
"'ca' directory already exists in
$root
, please remove it before running this script."
exit
1
fi
if
[
-z
"
$SSLPASS
"
]
;
then
# Unless specified otherwise, we'll use this as a password everywhere.
export
SSLPASS
=
"xmlsecurity"
fi
# 1) Create the root pair.
mkdir
"
$root
/ca"
cd
"
$root
/ca"
mkdir
certs crl newcerts private
chmod
700 private
touch
index.txt
echo
1000
>
serial
sed
"s|@ROOT@|
$root
|g"
"
$root
/templates/root.cnf"
>
"
$root
/ca/openssl.cnf"
# Create the root key.
cd
"
$root
/ca"
openssl genrsa
-aes256
-out
private/ca.key.pem
-passout
env
:SSLPASS 4096
chmod
400 private/ca.key.pem
# Create the root certificate.
cd
"
$root
/ca"
openssl req
-config
openssl.cnf
\
-key
private/ca.key.pem
\
-new
-x509
-days
7300
-sha256
-extensions
v3_ca
\
-out
certs/ca.cert.pem
\
-passin
env
:SSLPASS
\
-subj
'/C=UK/ST=England/O=Xmlsecurity Test/CN=Xmlsecurity Test Root CA'
chmod
444 certs/ca.cert.pem
# 2) Create the intermediate pair.
# Prepare the directory.
mkdir
"
$root
/ca/intermediate"
cd
"
$root
/ca/intermediate"
mkdir
certs crl csr newcerts private
chmod
700 private
touch
index.txt
echo
1000
>
serial
# crlnumber is used to keep track of certificate revocation lists.
echo
1000
>
"
$root
/ca/intermediate/crlnumber"
# Copy the intermediate CA configuration file.
sed
"s|@ROOT@|
$root
|g"
"
$root
/templates/intermediate.cnf"
>
"
$root
/ca/intermediate/openssl.cnf"
# Create the intermediate key.
cd
"
$root
/ca"
openssl genrsa
-aes256
\
-out
intermediate/private/intermediate.key.pem
\
-passout
env
:SSLPASS 4096
chmod
400 intermediate/private/intermediate.key.pem
# Create the intermediate certificate.
# Intermediate key.
cd
"
$root
/ca"
openssl req
-config
intermediate/openssl.cnf
-new
-sha256
\
-key
intermediate/private/intermediate.key.pem
\
-out
intermediate/csr/intermediate.csr.pem
\
-passin
env
:SSLPASS
\
-subj
'/C=UK/ST=England/O=Xmlsecurity Test/CN=Xmlsecurity Intermediate Root CA'
# The certificate itself.
openssl ca
-batch
-config
openssl.cnf
-extensions
v3_intermediate_ca
\
-days
3650
-notext
-md
sha256
\
-in
intermediate/csr/intermediate.csr.pem
\
-passin
env
:SSLPASS
\
-out
intermediate/certs/intermediate.cert.pem
chmod
444 intermediate/certs/intermediate.cert.pem
# Create the certificate chain file.
cat
intermediate/certs/intermediate.cert.pem
\
certs/ca.cert.pem
>
intermediate/certs/ca-chain.cert.pem
chmod
444 intermediate/certs/ca-chain.cert.pem
# 3) Create the real certificate.
for
i
in
Alice Bob
do
# Create a key.
cd
"
$root
/ca"
openssl genrsa
-aes256
\
-out
intermediate/private/example-xmlsecurity-
${
i
}
.key.pem
\
-passout
env
:SSLPASS 2048
chmod
400 intermediate/private/example-xmlsecurity-
${
i
}
.key.pem
# Create a certificate signing request (CSR).
cd
"
$root
/ca"
openssl req
-config
intermediate/openssl.cnf
\
-key
intermediate/private/example-xmlsecurity-
${
i
}
.key.pem
\
-new
-sha256
-out
intermediate/csr/example-xmlsecurity-
${
i
}
.csr.pem
\
-passin
env
:SSLPASS
\
-subj
"/C=UK/ST=England/O=Xmlsecurity Test/CN=Xmlsecurity Test example
${
i
}
"
# To create a certificate, use the intermediate CA to sign the CSR.
cd
"
$root
/ca"
# usr_cert: the cert will be used for signing.
openssl ca
-batch
-config
intermediate/openssl.cnf
\
-extensions
usr_cert
-days
375
-notext
-md
sha256
\
-in
intermediate/csr/example-xmlsecurity-
${
i
}
.csr.pem
\
-passin
env
:SSLPASS
\
-out
intermediate/certs/example-xmlsecurity-
${
i
}
.cert.pem
chmod
444 intermediate/certs/example-xmlsecurity-
${
i
}
.cert.pem
# Export it in PKCS#12 format.
openssl pkcs12
-export
\
-out
./intermediate/private/example-xmlsecurity-
${
i
}
.cert.p12
\
-passout
env
:SSLPASS
\
-inkey
intermediate/private/example-xmlsecurity-
${
i
}
.key.pem
\
-passin
env
:SSLPASS
\
-in
intermediate/certs/example-xmlsecurity-
${
i
}
.cert.pem
\
-certfile
intermediate/certs/ca-chain.cert.pem
done
echo
echo
"Authority certificate is at: <
$root
/ca/intermediate/certs/ca-chain.cert.pem>."
echo
"To be able to import it in Windows, rename the '.pem' extension to '.cer'."
for
i
in
Alice Bob
do
echo
"Signing certificate is at <
$root
/ca/intermediate/private/example-xmlsecurity-
${
i
}
.cert.p12>."
done
# vim:set shiftwidth=4 expandtab:
xmlsecurity/qa/create-certs/templates/intermediate.cnf
0 → 100644
Dosyayı görüntüle @
679cc560
# OpenSSL intermediate CA configuration file.
# Copy to `$root/ca/intermediate/openssl.cnf`.
[ ca ]
# `man ca`
default_ca = CA_default
[ CA_default ]
# Directory and file locations.
dir = @ROOT@/ca/intermediate
certs = $dir/certs
crl_dir = $dir/crl
new_certs_dir = $dir/newcerts
database = $dir/index.txt
serial = $dir/serial
RANDFILE = $dir/private/.rand
# The root key and root certificate.
private_key = $dir/private/intermediate.key.pem
certificate = $dir/certs/intermediate.cert.pem
# For certificate revocation lists.
crlnumber = $dir/crlnumber
crl = $dir/crl/intermediate.crl.pem
crl_extensions = crl_ext
default_crl_days = 30
# SHA-1 is deprecated, so use SHA-2 instead.
default_md = sha256
name_opt = ca_default
cert_opt = ca_default
default_days = 375
preserve = no
policy = policy_loose
[ policy_strict ]
# The root CA should only sign intermediate certificates that match.
# See the POLICY FORMAT section of `man ca`.
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ policy_loose ]
# Allow the intermediate CA to sign a more diverse range of certificates.
# See the POLICY FORMAT section of the `ca` man page.
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ req ]
# Options for the `req` tool (`man req`).
default_bits = 2048
distinguished_name = req_distinguished_name
string_mask = utf8only
# SHA-1 is deprecated, so use SHA-2 instead.
default_md = sha256
# Extension to add when the -x509 option is used.
x509_extensions = v3_ca
[ req_distinguished_name ]
# See <https://en.wikipedia.org/wiki/Certificate_signing_request>.
countryName = Country Name (2 letter code)
stateOrProvinceName = State or Province Name
localityName = Locality Name
0.organizationName = Organization Name
organizationalUnitName = Organizational Unit Name
commonName = Common Name
emailAddress = Email Address
# Optionally, specify some defaults.
countryName_default = GB
stateOrProvinceName_default = England
localityName_default =
0.organizationName_default = Xmlsecurity Test
organizationalUnitName_default =
emailAddress_default =
[ v3_ca ]
# Extensions for a typical CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ v3_intermediate_ca ]
# Extensions for a typical intermediate CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ 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
[ server_cert ]
# Extensions for server certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
[ crl_ext ]
# Extension for CRLs (`man x509v3_config`).
authorityKeyIdentifier=keyid:always
[ ocsp ]
# Extension for OCSP signing certificates (`man ocsp`).
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, digitalSignature
extendedKeyUsage = critical, OCSPSigning
xmlsecurity/qa/create-certs/templates/root.cnf
0 → 100644
Dosyayı görüntüle @
679cc560
# OpenSSL root CA configuration file.
# Copy to `$root/ca/openssl.cnf`.
[ ca ]
# `man ca`
default_ca = CA_default
[ CA_default ]
# Directory and file locations.
dir = @ROOT@/ca
certs = $dir/certs
crl_dir = $dir/crl
new_certs_dir = $dir/newcerts
database = $dir/index.txt
serial = $dir/serial
RANDFILE = $dir/private/.rand
# The root key and root certificate.
private_key = $dir/private/ca.key.pem
certificate = $dir/certs/ca.cert.pem
# For certificate revocation lists.
crlnumber = $dir/crlnumber
crl = $dir/crl/ca.crl.pem
crl_extensions = crl_ext
default_crl_days = 30
# SHA-1 is deprecated, so use SHA-2 instead.
default_md = sha256
name_opt = ca_default
cert_opt = ca_default
default_days = 375
preserve = no
policy = policy_strict
[ policy_strict ]
# The root CA should only sign intermediate certificates that match.
# See the POLICY FORMAT section of `man ca`.
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ policy_loose ]
# Allow the intermediate CA to sign a more diverse range of certificates.
# See the POLICY FORMAT section of the `ca` man page.
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ req ]
# Options for the `req` tool (`man req`).
default_bits = 2048
distinguished_name = req_distinguished_name
string_mask = utf8only
# SHA-1 is deprecated, so use SHA-2 instead.
default_md = sha256
# Extension to add when the -x509 option is used.
x509_extensions = v3_ca
[ req_distinguished_name ]
# See <https://en.wikipedia.org/wiki/Certificate_signing_request>.
countryName = Country Name (2 letter code)
stateOrProvinceName = State or Province Name
localityName = Locality Name
0.organizationName = Organization Name
organizationalUnitName = Organizational Unit Name
commonName = Common Name
emailAddress = Email Address
# Optionally, specify some defaults.
countryName_default = GB
stateOrProvinceName_default = England
localityName_default =
0.organizationName_default = Xmlsecurity Test
organizationalUnitName_default =
emailAddress_default =
[ v3_ca ]
# Extensions for a typical CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ v3_intermediate_ca ]
# Extensions for a typical intermediate CA (`man x509v3_config`).
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
basicConstraints = critical, CA:true, pathlen:0
keyUsage = critical, digitalSignature, cRLSign, keyCertSign
[ 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
[ server_cert ]
# Extensions for server certificates (`man x509v3_config`).
basicConstraints = CA:FALSE
nsCertType = server
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
[ crl_ext ]
# Extension for CRLs (`man x509v3_config`).
authorityKeyIdentifier=keyid:always
[ ocsp ]
# Extension for OCSP signing certificates (`man ocsp`).
basicConstraints = CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = critical, digitalSignature
extendedKeyUsage = critical, OCSPSigning
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment