jooby-project / jooby-project/jooby

Should we make SslOptions be more explicit about where it loads certifications?

Aperta
#3,766 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
1.8k
Fork
202
Merge medio
2g 9h
PR unite (30g)
6

Descrizione

I'm not sure I like the default fallback behavior here:

https://github.com/jooby-project/jooby/blob/e9b889d593f630182b0c28db50e24c0d65215d35/jooby/src/main/java/io/jooby/SslOptions.java#L245

Instead I recommend something more like:

     static InputStream getResource(
            String path)
            throws FileNotFoundException, IOException {

        URI uri = URI.create(path);

        /*
         * Explicit
         */
        if ("classpath".equals(uri.getScheme())) {
            var classpath = uri.getPath();
            if (classpath == null) {
                throw new FileNotFoundException(path);
            }
            return getClasspathResource(classpath);
        }
        if ("file".equals(uri.getScheme())) {
            return Files.newInputStream(Path.of(uri));

        }
        /*
         * Implicit
         */
        Path filepath = Paths.get(path);
        if (Files.exists(filepath)) {
            // absolute file:
            return Files.newInputStream(filepath);

        }
        // Maybe do not do this
        return getClasspathResource(path);
    }

This is where classpath:/// and file:/// can be explicitly used and then if that is not used we do the original behavior with the eventual goal of not doing the classpath unless it has the classpath uri schema.

The reason is assume I package a certification in the classpath. It works normally. Then someone adds a classpath on the filesystem when I go deploy. It now overrides the classpath one.

Now I admit this is unlikely and if this was not certs I could care less but I think we should not go around sniffing for certs. It also seems more inline with how we no longer use the service loader. That is less implicit behavior.

Otherwise I mostly don't care but just think this is the right thing to do.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo SslOptions.java intorno alla riga 245 e segui come vengono attualmente risolti i percorsi dei certificati. Confronta i casi espliciti classpath e file URI indicati nell’issue con il comportamento di fallback esistente, quindi conferma le regole di compatibilità previste e aggiungi la coverage per i percorsi di risoluzione concordati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
security
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.