Skip to content

Sentry.captureException(e) generate Envelope submission failed SSLHandshakeException PKIX path building failed #4254

@hernaldog

Description

@hernaldog

Integration

sentry-spring-boot-jakarta

Java Version

21.0.3

Version

8.3.0

Steps to Reproduce

Hi, I've been trying to solve this problem for 2.5 days and can't find a solution.

  1. Configure Sentry for a SpringBoot 3 project using sentry-spring-boot-starter-jakarta. I use Java 21, as indicated on the https://xxxx.sentry.io/ site when creating a new project. I Use Spring Tool Suite 4.23.1.RELEASE
  2. Add the Token and DSN in the application.properties file.
sentry.dsn=https://496ecee9b8f90beb6ee44b8c72aa3e8c@o4508846212186115.ingest.us.sentry.io/4508937126871040
sentry.send-default-pii=true
sentry.auth.token=xxxxxxx
sentry.proyecto=mi-proyecto2
sentry.debug=true
  1. Add this POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.4.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>cl.tisal</groupId>
	<artifactId>arq-poc-log-sentry</artifactId>
	<version>1</version>
	<name>arq</name>
	<description>Demo uso de Logs Sentry.io</description>
	<url/>
	<licenses>
		<license/>
	</licenses>
	<developers>
		<developer/>
	</developers>
	<scm>
		<connection/>
		<developerConnection/>
		<tag/>
		<url/>
	</scm>
	<properties>
		<java.version>21</java.version>
	</properties>
	<dependencies>	

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>		
		<dependency>
		    <groupId>io.sentry</groupId>
		    <artifactId>sentry-spring-boot-starter-jakarta</artifactId>
		    <version>8.3.0</version>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			
			<plugin>
		      <groupId>io.sentry</groupId>
		      <artifactId>sentry-maven-plugin</artifactId>
		      <version>0.3.0</version>
		      <extensions>true</extensions>
		      <configuration>		        
		        <debugSentryCli>true</debugSentryCli>		
		        <org>tisal-op</org>		
		        <!--<project>mi-proyecto2</project>-->
		        <project>${sentry.proyecto}</project>
		        <authToken>${sentry.auth.token}</authToken>
		      </configuration>
		       <executions>
			    <execution>
			      <goals>
			        <!-- Generates a source bundle and uploads it to Sentry -->
			        <!-- This enables source context, allowing you to see your source code as part of your stack traces in Sentry -->
			        <!-- Learn more about this feature in its dedicated "Source Context" docs page -->
			        <goal>uploadSourceBundle</goal>
			      </goals>
			    </execution>
			  </executions>
		    </plugin>		    
		</plugins>
	</build>

</project>

  1. Create a new controller using only the lines indicated in the example:
import java.lang.Exception;
import io.sentry.Sentry;

try {
throw new Exception("This is a test.");
} catch (Exception e) {
 Sentry.captureException(e);
}
  1. The output always on the line Sentry.captureException(e); It is in summary:

DEBUG: Hint is not io.sentry.hints.Retryable
ERROR: Envelope submission failed
java.lang.IllegalStateException: Sending the event failed.
java.lang.IllegalStateException: Sending the event failed.

Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

  1. I'm not sure which SSL certificate I need to add, what URL I'm getting it from, or where to add it or how to add it :( in case that's the problem

Expected Result

I was able to send the "This is a test." exception to the Sentry Cloud platform without an SSL certificate error.

Actual Result

Nothing is showing in Sentry.io cloud; it's not logging any events.

Below is the full error in "Console" section of my IDE



  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                 (v3.4.3)

2025-03-12T08:19:45.562-03:00  INFO 23184 --- [arq] [           main] cl.tisal.arq.ArqApplication              : Starting ArqApplication using Java 21.0.3 with PID 23184 (C:\desarrollos\arq-poc-log-sentry\target\classes started by hgonzalez in C:\desarrollos\arq-poc-log-sentry)
2025-03-12T08:19:45.590-03:00  INFO 23184 --- [arq] [           main] cl.tisal.arq.ArqApplication              : No active profile set, falling back to 1 default profile: "default"
2025-03-12T08:19:46.550-03:00  INFO 23184 --- [arq] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2025-03-12T08:19:46.569-03:00  INFO 23184 --- [arq] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2025-03-12T08:19:46.569-03:00  INFO 23184 --- [arq] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.36]
2025-03-12T08:19:46.625-03:00  INFO 23184 --- [arq] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2025-03-12T08:19:46.626-03:00  INFO 23184 --- [arq] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 954 ms
INFO: Initializing SDK with DSN: 'https://496ecee9b8f90beb6ee44b8c72aa3e8c@o4508846212186115.ingest.us.sentry.io/4508937126871040'
INFO: No outbox dir path is defined in options.
INFO: Debug Meta Data Properties loaded from file:/C:/desarrollos/arq-poc-log-sentry/target/classes/sentry-debug-meta.properties
DEBUG: Bundle IDs found: df483857-506f-42aa-aada-badbc4f31ddd
DEBUG: UncaughtExceptionHandlerIntegration enabled: true
DEBUG: UncaughtExceptionHandlerIntegration installed.
DEBUG: ShutdownHookIntegration installed.
DEBUG: SpotlightIntegration is not enabled. BeforeEnvelopeCallback is already set or spotlight is not enabled.
DEBUG: Using openTelemetryMode AUTO
INFO: Cache dir is not set, not finalizing the previous session.
DEBUG: Using span factory io.sentry.DefaultSpanFactory
DEBUG: Using scopes storage io.sentry.DefaultScopesStorage
2025-03-12T08:19:47.158-03:00  INFO 23184 --- [arq] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
2025-03-12T08:19:47.165-03:00  INFO 23184 --- [arq] [           main] cl.tisal.arq.ArqApplication              : Started ArqApplication in 2.067 seconds (process running for 3.244)
2025-03-12T08:20:10.920-03:00  INFO 23184 --- [arq] [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2025-03-12T08:20:10.920-03:00  INFO 23184 --- [arq] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2025-03-12T08:20:10.922-03:00  INFO 23184 --- [arq] [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms
DEBUG: Capturing event: d294107f886e4ad2bbdad54dd6ca32bb
INFO: sentry-external-modules.txt file was not found.
INFO: Session is null on scope.withSession
DEBUG: Hint is not io.sentry.hints.Retryable
ERROR: Envelope submission failed 
 java.lang.IllegalStateException: Sending the event failed.
java.lang.IllegalStateException: Sending the event failed.
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.flush(AsyncHttpTransport.java:337)
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.run(AsyncHttpTransport.java:244)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:130)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1318)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1195)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1138)
	at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:393)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:476)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:447)
	at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1506)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1421)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)
	at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:586)
	at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:187)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:141)
	at io.sentry.transport.HttpConnection.createConnection(HttpConnection.java:144)
	at io.sentry.transport.HttpConnection.send(HttpConnection.java:149)
	at io.sentry.transport.AsyncHttpTransport$EnvelopeSender.flush(AsyncHttpTransport.java:299)
	... 6 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:388)
	at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:271)
	at java.base/sun.security.validator.Validator.validate(Validator.java:256)
	at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:230)
	at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
	at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1302)
	... 23 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:148)
	at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:129)
	at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:383)
	... 28 more

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Done

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions