Skip to content

Commit 8abb7f0

Browse files
committed
Support importing credential file
1 parent fdb3d79 commit 8abb7f0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

nym-vpnc/src/main.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,13 @@ async fn import_credential(
148148
import_args: &ImportCredentialArgs,
149149
) -> anyhow::Result<()> {
150150
let import_type: ImportCredentialTypeEnum = import_args.credential_type.clone().into();
151-
let request = match import_type {
152-
ImportCredentialTypeEnum::Path(_path) => todo!(),
153-
ImportCredentialTypeEnum::Data(data) => {
154-
let bin = parse_encoded_credential_data(&data)?;
155-
tonic::Request::new(ImportUserCredentialRequest { credential: bin })
156-
}
151+
let raw_credential = match import_type {
152+
ImportCredentialTypeEnum::Path(path) => std::fs::read(path)?,
153+
ImportCredentialTypeEnum::Data(data) => parse_encoded_credential_data(&data)?,
157154
};
158-
155+
let request = tonic::Request::new(ImportUserCredentialRequest {
156+
credential: raw_credential,
157+
});
159158
let mut client = get_client(args).await?;
160159
let response = client.import_user_credential(request).await?.into_inner();
161160
println!("{:?}", response);

0 commit comments

Comments
 (0)