@@ -149,21 +149,21 @@ impl KeyConfig {
149
149
/// Returns the password in case any is provided.
150
150
///
151
151
/// If `password_file` was given, the password is read from that file.
152
- async fn password ( & self ) -> anyhow:: Result < Option < Cow < String > > > {
152
+ async fn password ( & self ) -> anyhow:: Result < Option < Cow < [ u8 ] > > > {
153
153
Ok ( match & self . password {
154
- Some ( Password :: File ( path) ) => Some ( Cow :: Owned ( tokio:: fs:: read_to_string ( path) . await ?) ) ,
155
- Some ( Password :: Value ( password) ) => Some ( Cow :: Borrowed ( password) ) ,
154
+ Some ( Password :: File ( path) ) => Some ( Cow :: Owned ( tokio:: fs:: read ( path) . await ?) ) ,
155
+ Some ( Password :: Value ( password) ) => Some ( Cow :: Borrowed ( password. as_bytes ( ) ) ) ,
156
156
None => None ,
157
157
} )
158
158
}
159
159
160
160
/// Returns the key.
161
161
///
162
162
/// If `key_file` was given, the key is read from that file.
163
- async fn key ( & self ) -> anyhow:: Result < Cow < String > > {
163
+ async fn key ( & self ) -> anyhow:: Result < Cow < [ u8 ] > > {
164
164
Ok ( match & self . key {
165
- Key :: File ( path) => Cow :: Owned ( tokio:: fs:: read_to_string ( path) . await ?) ,
166
- Key :: Value ( key) => Cow :: Borrowed ( key) ,
165
+ Key :: File ( path) => Cow :: Owned ( tokio:: fs:: read ( path) . await ?) ,
166
+ Key :: Value ( key) => Cow :: Borrowed ( key. as_bytes ( ) ) ,
167
167
} )
168
168
}
169
169
@@ -174,8 +174,8 @@ impl KeyConfig {
174
174
let ( key, password) = try_join ( self . key ( ) , self . password ( ) ) . await ?;
175
175
176
176
let private_key = match password {
177
- Some ( password) => PrivateKey :: load_encrypted ( key. as_bytes ( ) , password. as_bytes ( ) ) ?,
178
- None => PrivateKey :: load ( key. as_bytes ( ) ) ?,
177
+ Some ( password) => PrivateKey :: load_encrypted ( & key, password) ?,
178
+ None => PrivateKey :: load ( & key) ?,
179
179
} ;
180
180
181
181
Ok ( JsonWebKey :: new ( private_key)
0 commit comments