File tree Expand file tree Collapse file tree 2 files changed +23
-13
lines changed Expand file tree Collapse file tree 2 files changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ const mixin Crypto
101101 ** - '.p12', '.pfx': PKCS12 format
102102 ** - '.jks': Java KeyStore (JAVA only)
103103 **
104+ ** If the file does not have an extension, then PKCS12 format will be assumed.
104105 ** Other formats may be supported depending on the runtime implementation. Throws
105106 ** an Err if the format is not supported or there is a problem loading the keystore.
106107 **
Original file line number Diff line number Diff line change @@ -34,20 +34,29 @@ public class JKeyStorePeer
3434
3535 public static JKeyStore load (File file , Map opts )
3636 {
37- String format = null ;
38- String ext = "p12" ;
39- if (file != null ) ext = file .ext ();
40- switch (ext )
37+ // format option trumps file extension
38+ String format = (String )opts .get ("format" );
39+ if (format == null )
4140 {
42- case "p12" :
43- case "pfx" :
44- format = "pkcs12" ;
45- break ;
46- case "jks" :
47- format = "jks" ;
48- break ;
49- default :
50- throw UnsupportedErr .make ("Unsupported file ext: " + file .ext ());
41+ String ext = "p12" ;
42+ if (file != null )
43+ {
44+ // If the file doesn't have an extension, then default is pkcs12
45+ ext = file .ext ();
46+ if (ext == null ) ext = "p12" ;
47+ }
48+ switch (ext )
49+ {
50+ case "p12" :
51+ case "pfx" :
52+ format = "pkcs12" ;
53+ break ;
54+ case "jks" :
55+ format = "jks" ;
56+ break ;
57+ default :
58+ throw UnsupportedErr .make ("Unsupported file ext: " + file .ext ());
59+ }
5160 }
5261 return file == null
5362 ? JKeyStore .make (format , ConcurrentMap .make ())
You can’t perform that action at this time.
0 commit comments