无需言 做自己 业 ,精于勤 荒于嬉.
- OpenSSL 函数 openssl_spki_export_challenge 导出与签名公钥和挑战相关的挑战字符串
-
发表日期:2021-07-01 08:55:23 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $pkey = openssl_pkey_new('secret password'); $spkac = openssl_spki_new($pkey, 'challenge string'); $challenge = openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $spkac)); ?>示例2
<?php $challenge = openssl_spki_export_challenge(preg_replace('/SPKAC=/', '', $_POST['spkac'])); ?><keygen name="spkac" challenge="challenge string" keytype="RSA">
- OpenSSL 函数 openssl_spki_export 通过签名公钥和挑战导出一个可用的PEM格式的公钥
-
发表日期:2021-07-01 08:55:23 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $pkey = openssl_pkey_new('secret password'); $spkac = openssl_spki_new($pkey, 'challenge string'); $pubKey = openssl_spki_export(preg_replace('/SPKAC=/', '', $spkac)); if ($pubKey) { echo $pubKey; } ?>示例2
<?php $spkac = openssl_spki_export(preg_replace('/SPKAC=/', '', $_POST['spkac'])); if ($spkac != NULL) { echo $spkac; } else { echo "Extraction of pub key failed"; } ?><keygen name="spkac" challenge="challenge string" keytype="RSA">
- OpenSSL 函数 openssl_spki_new 生成一个新的签名公钥和挑战
-
发表日期:2021-07-01 08:55:23 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $pkey = openssl_pkey_new('secret password'); $spkac = openssl_spki_new($pkey, 'testing'); if ($spkac !== NULL) { echo $spkac; } else { echo "SPKAC generation failed"; } ?>
- OpenSSL 函数 openssl_x509_check_private_key 检查私钥是否对应于证书
-
发表日期:2021-07-01 08:55:23 | 来源: | 分类:OpenSSL 函数
-
openssl_x509_check_private_key
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
openssl_x509_check_private_key — 检查私钥是否对应于证书
说明
openssl_x509_check_private_key(mixed$cert, mixed$key): bool检查给定的私钥
key是否和证书cert对应。警告这个函数不会检查密钥
key是否真的是私钥。 它只是比较了和密钥匹配的公共材料 (比如,RSA密钥的指数和模量) 和/或密钥参数(比如,EC密钥的参数)。这也意味着,比如,提供给
key赋一个公钥值,该函数可能返回true.参数
-
cert -
证书。
-
key -
私钥。
返回值
如果给定的私钥
key和证书cert对应, 返回true否则返回false. -
- OpenSSL 函数 openssl_get_privatekey 别名 openssl_pkey_get_private()
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
openssl_get_privatekey
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
openssl_get_privatekey — 别名 openssl_pkey_get_private()
说明
此函数是该函数的别名: openssl_pkey_get_private().
- OpenSSL 函数 openssl_get_md_methods 获取可用的摘要算法
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $digests = openssl_get_md_methods(); $digests_and_aliases = openssl_get_md_methods(true); $digest_aliases = array_diff($digests_and_aliases, $digests); print_r($digests); print_r($digest_aliases); ?>
- OpenSSL 函数 openssl_get_publickey 别名 openssl_pkey_get_public()
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
openssl_get_publickey
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
openssl_get_publickey — 别名 openssl_pkey_get_public()
说明
此函数是该函数的别名: openssl_pkey_get_public().
- OpenSSL 函数 openssl_get_curve_names 获得ECC的可用曲线名称列表
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $curve_names = openssl_get_curve_names(); print_r($curve_names); ?>
- OpenSSL 函数 openssl_open 打开密封的数据
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php // $sealed and $env_key are assumed to contain the sealed data// and our envelope key, both given to us by the sealer.// fetch private key from file and ready it$fp = fopen("/src/openssl-0.9.6/demos/sign/key.pem", "r"); $priv_key = fread($fp, 8192); fclose($fp); $pkeyid = openssl_get_privatekey($priv_key); // decrypt the data and store it in $openif (openssl_open($sealed, $open, $env_key, $pkeyid)) { echo "here is the opened data: ", $open; } else { echo "failed to open data"; } // free the private key from memoryopenssl_free_key($pkeyid); ?>
- OpenSSL 函数 openssl_pkcs12_export 将 PKCS#12 兼容证书存储文件导出到变量
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
openssl_pkcs12_export
(PHP 5 >= 5.2.2, PHP 7, PHP 8)
openssl_pkcs12_export — 将 PKCS#12 兼容证书存储文件导出到变量
说明
openssl_pkcs12_export(
mixed$x509,
string&$out,
mixed$priv_key,
string$pass,
array$args= ?
): boolopenssl_pkcs12_export() 以 PKCS#12 文件格式 将
x509导入到以out命名类型为字符串的变量中。参数
-
x509 -
参见密钥/证书参数以获取有效值列表。
-
out -
成功,该字符串将为 PKCS#12 格式。
-
priv_key -
PKCS#12 文件的私钥部分file, 参见 公/私钥参数 获取更多可用列表。
-
pass -
用来解锁 PKCS#12 文件的解密密码。
-
args -
可选数组,其他主键将被忽略。
Key 说明 "extracerts"PKCS#12 文件中包含的额外证书或单个证书的数组。 "friendlyname"被证书和密钥使用的字符串
返回值
成功时返回
true, 或者在失败时返回false。 -
- OpenSSL 函数 openssl_pbkdf2 生成一个 PKCS5 v2 PBKDF2 字符串
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $password = 'yOuR-pAs5w0rd-hERe'; $salt = openssl_random_pseudo_bytes(12); $keyLength = 40; $iterations = 10000; $generated_key = openssl_pbkdf2($password, $salt, $keyLength, $iterations, 'sha256'); echo bin2hex($generated_key)."\n"; echo base64_encode($generated_key)."\n"; ?>
- OpenSSL 函数 openssl_pkcs7_decrypt 解密一个 S/MIME 加密的消息
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php // $cert and $key are assumed to contain your personal certificate and private// key pair, and that you are the recipient of an S/MIME message$infilename = "encrypted.msg"; // this file holds your encrypted message$outfilename = "decrypted.msg"; // make sure you can write to this fileif (openssl_pkcs7_decrypt($infilename, $outfilename, $cert, $key)) { echo "decrypted!"; } else { echo "failed to decrypt!"; } ?>
- OpenSSL 函数 openssl_pkcs7_encrypt 加密一个 S/MIME 消息
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php // the message you want to encrypt and send to your secret agent// in the field, known as nighthawk. You have his certificate// in the file nighthawk.pem$data = <<<EODNighthawk,Top secret, for your eyes only!The enemy is closing in! Meet me at the cafe at 8.30amto collect your forged passport!HQEOD; // load key$key = file_get_contents("nighthawk.pem"); // save message to file$fp = fopen("msg.txt", "w"); fwrite($fp, $data); fclose($fp); // encrypt itif (openssl_pkcs7_encrypt("msg.txt", "enc.txt", $key, array("To" => "nighthawk@example.com", // keyed syntax "From: HQ <hq@example.com>", // indexed syntax "Subject" => "Eyes only"))) { // message encrypted - send it! exec(ini_get("sendmail_path") . " < enc.txt"); } ?>
- OpenSSL 函数 openssl_pkcs7_sign 对一个 S/MIME 消息进行签名
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php // the message you want to sign so that recipient can be sure it was you that// sent it$data = <<<EODYou have my authorization to spend $10,000 on dinner expenses.The CEOEOD; // save message to file$fp = fopen("msg.txt", "w"); fwrite($fp, $data); fclose($fp); // encrypt itif (openssl_pkcs7_sign("msg.txt", "signed.txt", "file://mycert.pem", array("file://mycert.pem", "mypassphrase"), array("To" => "joes@example.com", // keyed syntax "From: HQ <ceo@example.com>", // indexed syntax "Subject" => "Eyes only") )) { // message signed - send it! exec(ini_get("sendmail_path") . " < signed.txt"); } ?>
- OpenSSL 函数 openssl_pkcs7_read 将 PKCS7 文件导出为 PEM 格式证书的数组
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php $file = 'certs.p7b'; $f = file_get_contents($file); $p7 = array(); $r = openssl_pkcs7_read($f, $p7); if ($r === false) { printf("ERROR: %s is not a proper p7b file".PHP_EOL, $file); for($e = openssl_error_string(), $i = 0; $e; $e = openssl_error_string(), $i++) printf("SSL l%d: %s".PHP_EOL, $i, $e); exit(1); } print_r($p7); ?>
- OpenSSL 函数 openssl_pkcs7_verify 校验一个已签名的 S/MIME 消息的签名
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
openssl_pkcs7_verify
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
openssl_pkcs7_verify — 校验一个已签名的 S/MIME 消息的签名
说明
openssl_pkcs7_verify(
string$filename,
int$flags,
string$outfilename= ?,
array$cainfo= ?,
string$extracerts= ?,
string$content= ?,
string$p7bfilename= ?
): mixedopenssl_pkcs7_verify() 读取给定文件中的 S/MIME 消息并且检查数字签名。
参数
-
filename -
消息的路径。
-
flags -
flags可以用来影响如何校验签名 - 参见 PKCS7 常量 获取更多信息。 -
outfilename -
如果已指定
outfilename输出文件,它应该是一个用以保存文件的字符串名称,签名消息的个人证书将以 PEM 的格式保存起来。 -
cainfo -
如果
cainfo被指定了,它应该保存关于受信任的CA证书的信息供在验证过程中使用 - 参见 证书校验 获取关于该参数的更多信息。 -
extracerts -
如果
extracerts被指定了,该文件包含了一堆会被作为不受信任的ca使用的证书。 -
content -
你可以使用
content来指定带有已被验证数据的文件名,该文件内容已去掉了签名信息。 -
p7bfilename -
返回值
如果签名已被认证,返回
true, 如果不正确 (消息已被篡改或者签名证书不可用) 则返回false, 或者 - 错误时返回1.更新日志
版本 说明 7.2.0 新增 p7bfilename参数。注释
注意: 正如 RFC 2045 中指定的,
filename参数最多不可超过 76 个字符串。 -
- OpenSSL 函数 openssl_pkcs12_read 将 PKCS#12 证书存储区解析到数组中
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php if (!$cert_store = file_get_contents("/certs/file.p12")) { echo "Error: Unable to read the cert file\n"; exit; } if (openssl_pkcs12_read($cert_store, $cert_info, "my_secret_pass")) { echo "Certificate Information\n"; print_r($cert_info); } else { echo "Error: Unable to read the cert store.\n"; exit; } ?>
- OpenSSL 函数 openssl_pkey_export 将一个密钥的可输出表示转换为字符串
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
openssl_pkey_export
(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)
openssl_pkey_export — 将一个密钥的可输出表示转换为字符串
说明
openssl_pkey_export(
mixed$key,
string&$out,
string$passphrase= ?,
array$configargs= ?
): boolopenssl_pkey_export() 将
key当作 PEM 编码字符串导出并且将之保存到out(通过引用传递的)中。注意: 必须安装有效的 openssl.cnf 以保证此函数正确运行。参考有关安装的说明以获得更多信息。
参数
-
key -
-
out -
-
passphrase -
密钥可以通过
passphrase来保护。 -
configargs -
configargs可以用来调整导出流程,通过指定或者覆盖openssl配置文件选项。参见 openssl_csr_new() 获取更多关于configargs的信息。
返回值
成功时返回
true, 或者在失败时返回false。 -
- OpenSSL 函数 openssl_pkcs12_export_to_file 输出一个 PKCS#12 兼容的证书存储文件
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
openssl_pkcs12_export_to_file
(PHP 5 >= 5.2.2, PHP 7, PHP 8)
openssl_pkcs12_export_to_file — 输出一个 PKCS#12 兼容的证书存储文件
说明
openssl_pkcs12_export_to_file(
mixed$x509,
string$filename,
mixed$priv_key,
string$pass,
array$args= ?
): boolopenssl_pkcs12_export_to_file() 函数以 PKCS#12 格式将
x509保存至文件名为filename的文件中。参数
-
x509 -
参见密钥/证书参数以获取有效值列表。
-
filename -
输出文件的路径。
-
priv_key -
PKCS#12文件的私钥部分。 参见 公/私钥参数 获取可用值的列表。
-
pass -
用于解锁 PKCS#12 文件的加密密码。
-
args -
可选数组,其他主键将被忽略。
Key 说明 "extracerts"PKCS#12 文件中包含的额外证书或单个证书的数组。 "friendlyname"被证书和密钥使用的字符串
返回值
成功时返回
true, 或者在失败时返回false。 -
- OpenSSL 函数 openssl_pkey_derive Computes shared secret for public value of remote and local DH or ECDH key
-
发表日期:2021-07-01 08:55:22 | 来源: | 分类:OpenSSL 函数
-
示例1
<?php // Load in private key$priv = openssl_pkey_get_private("-----BEGIN PRIVATE KEY-----MIICJgIBADCCARcGCSqGSIb3DQEDATCCAQgCggEBAJLxRCaZ933uW+AXmabHFDDyupojBIRlbmQLJZfigDaSA1f9YOTsIv+WwVFTX/J1mtCyx9uBcz0Nt2kmVwxWuc2fVtCEMPsmLsVXX7xRUFLpyX1Y1IYGBVXQOoOvLWYQjpZgnx47Pkh1Ok1+smffztfC0DCNt4KorWrbsPcmqBejXHN79KvWFjZmXOksRiNu/Bn76RiqvofC4z8Ri3kHXQG2197JGZzzFXHadGC3xbkg8UxsNbYhVMKbm0iANfafUH7/hoS9UjAVQYtvwe7YNiW/HnyfVCrKwcc7sadd8Iphh+3lf5P1AhaQEAMytanrzq9RDXKBxuvpSJifRYasZYsCAQIEggEEAoIBAGwAYC2E81Y1U2Aox0U7u1+vBcbht/OO87tutMvc4NTLf6NLPHsWcPqBixs+3rSn4fADzAIvdLBmogjtiIZoB6qyHrllF/2xwTVGEeYaZIupQH3bMK2b6eUvnpuu4Ytksiz6VpXBBRMrIsj3frM+zUtnq8vKUr+TbjV2qyKR8l3eNDwzqz30dlbKh9kIhZafclHfRVfyp+fVSKPfgrRAcLUgAbsVjOjPeJ90xQ4DTMZ6vjiv6tHMhkSjJIcGhRtSBzVF/cT38GyCeTmiIA/dRz2d70lWrqDQCdp9ArijgnpjNKAAulSYCirnMsGZTDGmLOHg4xOZ5FEAzZI2sFNLlcw=-----END PRIVATE KEY-----"); // Load in public key$pub = openssl_pkey_get_public("-----BEGIN PUBLIC KEY-----MIICJDCCARcGCSqGSIb3DQEDATCCAQgCggEBAJLxRCaZ933uW+AXmabHFDDyupojBIRlbmQLJZfigDaSA1f9YOTsIv+WwVFTX/J1mtCyx9uBcz0Nt2kmVwxWuc2fVtCEMPsmLsVXX7xRUFLpyX1Y1IYGBVXQOoOvLWYQjpZgnx47Pkh1Ok1+smffztfC0DCNt4KorWrbsPcmqBejXHN79KvWFjZmXOksRiNu/Bn76RiqvofC4z8Ri3kHXQG2197JGZzzFXHadGC3xbkg8UxsNbYhVMKbm0iANfafUH7/hoS9UjAVQYtvwe7YNiW/HnyfVCrKwcc7sadd8Iphh+3lf5P1AhaQEAMytanrzq9RDXKBxuvpSJifRYasZYsCAQIDggEFAAKCAQAiCSBpxvGgsTorxAWtcAlSmzAJnJxFgSPef0g7OjhESytnc8G2QYmxovMt5KVergcitztWh08hZQUdAYm4rI+zMlAFDdN8LWwBT/mGKSzRkWeprd8E7mvyucqC1YXCMqmIwPySvLQUB/Dl8kgau7BLAnIJm8VP+MVrn8g9gghD0qRCgPgtEaDVvocfgnOU43rhKnIgO0cHOKtw2qybSFB8QuZrYugq4j8Bwkrzh6rdMMeyMl/ej5Ajc0wamOzuBDtXt0T9+Fx3khHaowjCc7xJZRgZCxg43SbqMWJ9lUg94I7+LTX61GyvdtlkbGbtoDOnxeNnN93gwQZngGYZYciu-----END PUBLIC KEY-----"); // Outputs the hex version of the derived keyecho bin2hex(openssl_pkey_derive($pub,$priv));
- 前端开发(1)
- 数据库(0)
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)
- JAVA(0)
- Android(0)
- Linux(0)
- AI大模型(9)
- 其他(0)
宁公网安备 64010402001209号