phax / phase4

phase4 - AS4 client and server for integration into existing systems. Specific support for Peppol and CEF eDelivery built-in.
Apache License 2.0
157 stars 48 forks source link

aAPCertificate parameter in IPhase4PeppolCertificateCheckResultHandler is Nullable #206

Closed Florianisme closed 10 months ago

Florianisme commented 10 months ago

Hi Philip,

I have encountered a NPE while sending an outbound Peppol message because I relied on the @Nonnull annotation in IPhase4PeppolCertificateCheckResultHandler for the @Nonnull X509Certificate aAPCertificate parameter.

java.lang.NullPointerException: Cannot invoke "java.security.cert.X509Certificate.getSubjectX500Principal()" because "certificate" is null at 
de.i.p.o.OutboundMessageProcessor.lambda$buildCertificateConsumer$3(OutboundMessageProcessor.java:160) at 
com.helger.phase4.peppol.Phase4PeppolSender$AbstractPeppolUserMessageBuilder.finishFields(Phase4PeppolSender.java:801) at 
com.helger.phase4.peppol.Phase4PeppolSender$Builder.finishFields(Phase4PeppolSender.java:1344) at 
com.helger.phase4.sender.AbstractAS4MessageBuilder.sendMessage(AbstractAS4MessageBuilder.java:831) at 
com.helger.phase4.sender.AbstractAS4UserMessageBuilder.sendMessageAndCheckForReceipt(AbstractAS4UserMessageBuilder.java:798) 

Going through the code I can see where this is coming from:

Phase4PeppolSender.java (m_bCheckReceiverAPCertificate is false) image

From this point onwards the certificate is declared as Nullable: AS4EndpointDetailProviderPeppol.java image

phax commented 10 months ago

Thanks, fixed in the upcoming 2.7.0 release. All other parameters are indeed non-null.