Dam*_*les 7 security ssh wireless-networking certificate ssl
这听起来很疯狂,但我可以成为根证书颁发机构吗?我的意思是,我家里有很多电脑和智能设备。
当我从网络共享文件夹运行 EXE 时,它还警告该 EXE 未签名。
SSH 也会对证书发出警告
所以,为了做到这些,我可以颁发证书,我的所有设备都应该接受这些作为有效、可信的证书。以下是我想象中的场景:
像这样的事情是可能的,还是我应该购买真正的证书?再一次,仅用于本地区域使用。
小智 4
您可以像我按照本教程所做的那样进行操作。
\n在 Linux 上创建私有证书颁发机构
\n本教程将向您展示如何创建您自己的私有 CA 或证书颁发机构。这将使您有机会签署自己的证书,而无需向其他人付费。但是,由于您的私有 CA 不会被其他人信任,因此当其他人使用它时可能会提示警告。您需要将根证书添加到您想要信任 CA 的计算机。
\n我在 2008 年写过一篇类似的文章(使用 OpenSSL 创建证书颁发机构和证书),但本教程取代了在旧文章中创建 CA 的说明。\n安装先决条件
\n我使用 Fedora 18 编写了本教程。我需要的唯一先决条件是 OpenSSL。
\nsu -c \'yum install openssl\'\nCreate Directory Structure\n\nmkdir /home/cg/myca\n\ncd /home/cg/myca/\n\nmkdir private certs newcerts conf export csr\n\necho \'01\' > serial\n\ntouch index.txt\nRun Code Online (Sandbox Code Playgroud)\n除非另有说明,我们将默认在 /home/cg/myca 目录中运行所有命令。\n配置文件
\nvim /home/cg/myca/conf/caconfig.cnf\nRun Code Online (Sandbox Code Playgroud)\n该文件将作为 CA 的默认配置文件。它应该类似于以下内容:
\n[ ca ]\ndefault_ca = CA_default\n\n[ CA_default ]\ndir = /home/cg/myca/\ncerts = $dir/certs\ncrl_dir = $dir/crl\ndatabase = $dir/index.txt\nnew_certs_dir = $dir/newcerts\ncertificate = $dir/certs/cacert.pem\nserial = $dir/serial\n#crl = $dir/crl.pem\nprivate_key = $dir/private/cakey.pem\n#RANDFILE = $dir/private/.rand\nx509_extensions = usr_cert\n#crl_extensions = crl_ext\ndefault_days = 3650\n#default_startdate = YYMMDDHHMMSSZ\n#default_enddate = YYMMDDHHMMSSZ\n#default_crl_days= 30\n#default_crl_hours = 24\ndefault_md = sha1\npreserve = no\n#msie_hack\npolicy = policy_match\n\n[ policy_match ]\ncountryName = match\nstateOrProvinceName = match\nlocalityName = match\norganizationName = match\norganizationalUnitName = optional\ncommonName = supplied\nemailAddress = optional\n\n[ req ]\ndefault_bits = 4096 # Size of keys\ndefault_keyfile = key.pem # name of generated keys\ndistinguished_name = req_distinguished_name\nattributes = req_attributes\nx509_extensions = v3_ca\n#input_password\n#output_password\nstring_mask = nombstr # permitted characters\nreq_extensions = v3_req\n\n[ req_distinguished_name ]\ncountryName = Country Name (2 letter code)\ncountryName_default = US\ncountryName_min = 2\ncountryName_max = 2\nstateOrProvinceName = State or Province Name (full name)\nstateOrProvinceName_default = New York\nlocalityName = Locality Name (city, district)\nlocalityName_default = New York\norganizationName = Organization Name (company)\norganizationName_default = Code Ghar\norganizationalUnitName = Organizational Unit Name (department, division)\norganizationalUnitName_default = IT\ncommonName = Common Name (hostname, FQDN, IP, or your name)\ncommonName_max = 64\ncommonName_default = CGIT\nemailAddress = Email Address\nemailAddress_max = 40\nemailAddress_default = codeghar@example.com\n\n[ req_attributes ]\n#challengePassword = A challenege password\n#challengePassword_min = 4\n#challengePassword_max = 20\n#unstructuredName = An optional company name\n\n[ usr_cert ]\nbasicConstraints= CA:FALSE\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid,issuer:always\n#nsComment = \'\'OpenSSL Generated Certificate\'\'\n#nsCertType = client, email, objsign for \'\'everything including object signing\'\'\nsubjectAltName=email:copy\nissuerAltName=issuer:copy\n#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem\n#nsBaseUrl = \n#nsRenewalUrl =\n#nsCaPolicyUrl = \n#nsSslServerName =\n\n[ v3_req ]\nbasicConstraints = CA:FALSE\nkeyUsage = nonRepudiation, digitalSignature, keyEncipherment\n\n[ v3_ca ]\nsubjectKeyIdentifier = hash\nauthorityKeyIdentifier = keyid:always,issuer:always\nbasicConstraints = CA:TRUE\n#keyUsage = cRLSign, keyCertSign\n#nsCertType = sslCA, emailCA\n#subjectAltName=email:copy\n#issuerAltName=issuer:copy\n#obj=DER:02:03\n\n[ crl_ext ]\n#issuerAltName=issuer:copy\nauthorityKeyIdentifier=keyid:always,issuer:always\nRun Code Online (Sandbox Code Playgroud)\n感谢http://wwwneu.secit.at/web/documentation/openssl/openssl_cnf.html帮助处理此文件。
\n您可以使用我们在上一步中创建的配置文件 (caconfig.cnf) 来回答证书生成过程中提出的许多问题。只需运行以下命令并回答问题即可。大多数问题都会有 caconfig.cnf 中提供的默认值。
\nopenssl req -new -x509 -days 3650 -config conf/caconfig.cnf -keyform PEM -keyout private/key.ca.cg.pem -outform PEM -out certs/crt.ca.cg.pem
\n尽管我们在 caconfig.cnf 文件中指定了默认天数,但在使用 x509 标志时,我们仍然必须指定天数标志。如果我们不\xe2\x80\x99t,则会创建默认值为 30 天的证书。感谢回复:default_days 问题和 OpenSSL req(1)。
\n如果您想提供自己的自定义值,您可以运行以下命令。
\nopenssl req -new -x509 -days 3650 -newkey rsa:4096 -extensions v3_ca -keyform PEM -keyout private/key.ca.cg.pem -outform PEM -out certs/crt.ca.cg.pem
\n系统会要求您输入密码。确保您使用安全密码并且不要忘记\xe2\x80\x99。您还将被问及其他相关问题。以下是该过程的示例输出。
\nGenerating a 4096 bit RSA private key\n..............................................................................++\n...........................................................................................................................................................................................................................................++\nwriting new private key to \'private/key.ca.cg.pem\'\nEnter PEM pass phrase:\nVerifying - Enter PEM pass phrase:\n-----\nYou are about to be asked to enter information that will be incorporated\ninto your certificate request.\nWhat you are about to enter is what is called a Distinguished Name or a DN.\nThere are quite a few fields but you can leave some blank\nFor some fields there will be a default value,\nIf you enter \'.\', the field will be left blank.\n-----\nCountry Name (2 letter code) [US]:\nState or Province Name (full name) [New York]:\nLocality Name (city, district) [New York]:\nOrganization Name (company) [Code Ghar]:\nOrganizational Unit Name (department, division) [IT]:\nCommon Name (hostname, FQDN, IP, or your name) [CGIT]:\nEmail Address [codeghar@example.com]:\n\nTwo files, key.ca.cg.pem and crt.ca.cg.pem, will be created in $dir/private and $dir/certs directories respectively. Make sure you keep these files in a secure place and make their backups.\n\ncrt.ca.cg.pem is your root certificate and will be used to sign all the other certificates.\nRun Code Online (Sandbox Code Playgroud)\n您应该验证证书是否已使用准确的信息正确创建。
\nopenssl x509 -in certs/crt.ca.cg.pem -inform pem -noout -text\nRun Code Online (Sandbox Code Playgroud)\n由于这个新创建的 CA 及其根证书不被任何计算机识别和信任,因此您需要在所有其他计算机上导入根证书。默认情况下,操作系统将有一个受信任的 CA 列表,您需要将您的 CA 导入到该列表中。对于不同的操作系统,该过程有所不同。
\n我们创建的根证书采用 PEM 编码格式。对于 Windows,我们需要它采用 DER 编码格式。关于两者之间差异的一个很好的资源是 DER vs. CRT vs. CER vs. PEM 证书以及如何转换它们。
\nopenssl x509 -in certs/crt.ca.cg.pem -outform der -out export/ca.cg.crt\nRun Code Online (Sandbox Code Playgroud)\n验证证书已成功创建。
\nopenssl x509 -in export/ca.cg.crt -inform der -noout -text\nRun Code Online (Sandbox Code Playgroud)\n导出文件后,将其复制到 Windows 计算机。您可以按照如何在 Windows 中导入受信任的根证书颁发机构提供的说明将证书导入到本地计算机上的受信任的根证书颁发机构存储中。
\n您还可以将证书导出为 PKCS12 格式。感谢将用户证书导入到 Windows 证书存储区以获取此信息。
\nopenssl pkcs12 -export -out export/ca.cg.p12 -in certs/crt.ca.cg.pem -inkey private/key.ca.cg.pem\nRun Code Online (Sandbox Code Playgroud)\n系统将要求您提供用于创建根证书的密码。系统还会要求您输入新的 \xe2\x80\x9cExport Password\xe2\x80\x9d。
\n将 .p12 文件复制到 Windows 并双击它。将打开一个向导并指导您安装它。
\n创建 CA 的过程非常简单。接下来我将写有关签署证书请求的内容。
\n| 归档时间: |
|
| 查看次数: |
7197 次 |
| 最近记录: |