File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -339,6 +339,10 @@ public void run() {
339339 private long readAndUpdate (File trustCertFile , long oldTime )
340340 throws IOException , GeneralSecurityException {
341341 long newTime = checkNotNull (trustCertFile , "trustCertFile" ).lastModified ();
342+ if (newTime == 0 ) {
343+ throw new IOException (
344+ "Certificate file not found or not readable: " + trustCertFile .getAbsolutePath ());
345+ }
342346 if (newTime == oldTime ) {
343347 return oldTime ;
344348 }
Original file line number Diff line number Diff line change @@ -142,6 +142,17 @@ record -> record.getMessage().contains("Default value of "));
142142 }
143143 }
144144
145+ @ Test
146+ public void missingFile_throwsFileNotFoundException () throws Exception {
147+ AdvancedTlsX509TrustManager trustManager = AdvancedTlsX509TrustManager .newBuilder ().build ();
148+ File nonExistentFile = new File ("missing_cert.pem" );
149+ Exception thrown =
150+ assertThrows (Exception .class , () -> trustManager .updateTrustCredentials (nonExistentFile ));
151+ assertNotNull (thrown );
152+ assertEquals (thrown .getMessage (),
153+ "Certificate file not found or not readable: " + nonExistentFile .getAbsolutePath ());
154+ }
155+
145156 @ Test
146157 public void clientTrustedWithSocketTest () throws Exception {
147158 AdvancedTlsX509TrustManager trustManager = AdvancedTlsX509TrustManager .newBuilder ()
You can’t perform that action at this time.
0 commit comments