2

Java API を使用して、Luna HSM に保存されている公開鍵にアクセスしようとしています。対応する公開鍵のラベル名を出力することはできますが、公開鍵を取得しようとすると、その公開鍵への参照を取得できません。コード スニペットは次のとおりです。

        KeyStore ks = KeyStore.getInstance("Luna");
        ks.load(null, null); 
        lunaProvider = ks.getProvider();

        publicKey = (PublicKey) ks.getKey(alipayImpl.getHsmKeyStorePublicEntryName(), null);

        // ****************************************************************************
        // ** If the private keystore is not found, return original barcode string.  **
        // ****************************************************************************
        if (publicKey == null) {
            throw new Exception("Unable to acquire the Public Key " + alipayImpl.getHsmKeyStorePublicEntryName() + ", Hash will not be verified.");
        }
        // ***********************************************************
        // ** Create a Signature Object and sign the encrypted text **
        // ***********************************************************
        Signature signatureObject = Signature.getInstance(alipayImpl.getAlipaySignAlgorithm(), lunaProvider);

        signatureObject.initVerify(publicKey);
        signatureObject.update(signedMessage
                .getBytes(AlipayConstants.INPUT_CHARSET_VALUE));
        isValidSign = signatureObject.verify(Base64.decode(hash));

HSM に正しくログインしています。秘密鍵にアクセスしている間、問題はありませんでした。Luna HSM には、証明書を介してのみ公開鍵へのアクセスが許可されるという制限はありますか?

前もって感謝します。

4

2 に答える 2