小编fuk*_*chi的帖子

无法从Common Lisp中的p12文件中提取信息

我正在尝试从Common Lisp中的PKCS#12加密的客户端证书中提取信息.

我尝试过以下步骤:

  1. 加载给定的P12文件到BIOd2i_PKCS12_bio
  2. 使用验证密码 PKCS12_verify_mac
  3. 解析文件 PKCS12_parse

这是实际的CFFI代码:

(defun load-pkcs12 (file &optional passphrase)
  (openssl-add-all-digests)
  (pkcs12-pbe-add)
  ;; 1. Load the given p12 file
  (let ((content (slurp-file file)))
    (cffi:with-pointer-to-vector-data (data-sap content)
      (let* ((bio (bio-new-mem-buf data-sap (length content)))
             (p12 (d2i-pkcs12-bio bio (cffi:null-pointer)))
             (pkey (evp-pkey-new))
             (cert (x509-new)))
        (unwind-protect
             (progn
               ;; 2. Verify the passphrase
               (let ((res (pkcs12-verify-mac p12 (or passphrase (cffi:null-pointer)) (length passphrase))))
                 (when (zerop res)
                   (error (format nil "Error while verifying mac~%~A" (get-errors)))))

               ;; 3. Parse the file
               (cffi:with-foreign-objects …
Run Code Online (Sandbox Code Playgroud)

openssl common-lisp cffi

7
推荐指数
1
解决办法
241
查看次数

标签 统计

cffi ×1

common-lisp ×1

openssl ×1