@Test
public void getSignedByIssuer_withSubjectKeyIdentifier_setsAuthorityKeyIdentifier() throws Exception {

  when(serialNumberGenerator.generate())
    .thenReturn(BigInteger.valueOf(1337))
    .thenReturn(BigInteger.valueOf(666));
  final X509Certificate generatedCertificate =
    subject.getSignedByIssuer(generatedCertificateKeyPair, certificateGenerationParameters, certificateAuthorityWithSubjectKeyId, issuerKey.getPrivate());
  final byte[] authorityKeyIdDer = generatedCertificate.getExtensionValue(Extension.authorityKeyIdentifier.getId());
  final AuthorityKeyIdentifier authorityKeyIdentifier =
    AuthorityKeyIdentifier.getInstance(parseExtensionValue(authorityKeyIdDer));
  assertThat(authorityKeyIdentifier.getKeyIdentifier(), equalTo(caSubjectKeyIdentifier.getKeyIdentifier()));
}