0
мне кажется, что Надувной замок изменил API и следующий код не работает больше в 1,52:Надувной замок отделённая подпись изменилась апи
/**
* SignatureInterface implementation. Creates detached signature of stream
* using SHA-256.
*
* @param content
* original content stream to sign
* @throws SignatureException
* in case of signature error
* @throws IOException
* in case of I/O error
* @return signed byte content
*/
@Override
public byte[] sign(final InputStream content) throws SignatureException,
IOException {
try {
CMSProcessableInputStream input = new CMSProcessableInputStream(content);
List<Certificate> certList = Arrays.asList(keystore
.getCertificateChain(alias));
CertStore certStore = CertStore.getInstance("Collection",
new CollectionCertStoreParameters(certList), provider);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
gen.addSigner((PrivateKey) keystore.getKey(alias, pin),
(X509Certificate) keystore.getCertificate(alias),
CMSSignedGenerator.DIGEST_SHA256);
gen.addCertificatesAndCRLs(certStore);
return gen.generate(input, false, provider).getEncoded();
} catch (Exception e) {
throw new SignatureException(
"Problem while preparing signature. Wrong certificate or alias.");
}
}
Кто-нибудь знает, как добиться такого же поведения в новых API? Я не нашел никакой важной информации в руководстве по переносу.
редактируется (добавлено определение переменных):
/**
* Size of the read buffer for signing.
*/
private static final int BUFSIZE = 8192;
/**
* Stored instance of BC.
*/
private BouncyCastleProvider provider;
/**
* PKCS#12 key store.
*/
private KeyStore keystore;
/**
* Alias for certificate to sign.
*/
private String alias;
/**
* Password to private key.
*/
private char[] pin;