【问题标题】:do_convert_from_pkcs8: /dev/fd/63 is not a recognised public key formatdo_convert_from_pkcs8:/dev/fd/63 不是可识别的公钥格式
【发布时间】:2018-07-23 01:23:22
【问题描述】:

我正在尝试使用以下脚本检索我的 PIV 密钥:

getPIVkey.sh

NAME=`security find-certificate | grep PIV | sed 's;keychain:";;g' | sed 's;";;g'`
echo $NAME
ssh-keygen -i -m pkcs8 -f <(security find-certificate -p "$NAME" | openssl x509 -noout -pubkey)

在 Mac OS High Sierra 10.13.4 上。我明白了:

./getPIVPub.sh

keychain: PIV-Bill K Brown (piv)
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
    unable to load certificate
    140735828857800:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.50.2/libressl/crypto/pem/pem_lib.c:704:Expecting: TRUSTED CERTIFICATE
    do_convert_from_pkcs8: /dev/fd/63 is not a recognised public key format

【问题讨论】:

    标签: ssh openssl ssh-keygen


    【解决方案1】:

    您的第一个sed 命令中的keychain: 和引号之间似乎缺少一个空格。所以你设置NAME变量的命令应该是

    NAME=`security find-certificate | grep PIV | sed 's;keychain: ";;g' | sed 's;";;g'`
    

    使用改进的sed 命令,NAME 的(打印)值不应再以keychain: 开头,而只包含名称。

    由于NAME 中的值错误,第二个security find-certificate 命令失败,因此输出The specified output could not be found in the keychain.。之后执行的命令也会失败。

    仅供参考,引用/dev/fd/63的原因在问题Why does process substitution result in a file called /dev/fd/63 which is a pipe?的答案中进行了解释

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 2020-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 2022-01-26
      相关资源
      最近更新 更多