Firefox - add certificate with certutil.exe - Windows XP - windows

I'm trying to import a certificate via cmd with certutil.exe
After I tried this command:
certutil.exe -A -n C:\Documents and Settings\xxxxx\Desktop\RootCert-somecert.cer -t c
It returns me
certutil.exe: function failed: The certificate/key database is in an old, unsupported format
Can you help me?

make sure that the key3.db, cert8.db and secmod.db is in the same directory and in the current directory where you run the certutil. If you want to point another directory for the db, use -d argument.
-n argument is used to give alias to the certificate. To point the certificate to add, use the -i argument.
example:
certutil.ex -A -n "mycert" -i "C:\Documents and Settings\xxxxx\Desktop\RootCert-somecert.cer" -t c -d "C:\certdb"
hope it helps

Related

Why -f flag of ssh-keygen fails to follow symlink?

My ~/.ssh directory is a symlink to /somewhere/else/.ssh/
Now, the following works perfectly; and the demo key ends up getting created at /somewhere/else/.ssh/Official, as expected.
export NewUser="Sam"
ssh-keygen -N "" -t rsa -b 8192 -C "Login Key of ${NewUser}." -f ~/.ssh/Official/demo
However, when -f is supplied with the same path but via a variable, it fails with the following error:
Saving key "~/.ssh/Official/demo" failed: No such file or directory
export NewUser="Darsh"
export SSHKey_Path="~/.ssh/Official/demo"
ssh-keygen -N "" -t rsa -b 8192 -C "Login Key of ${NewUser}." -f ${SSHKey_Path}
I have tried several ways to supply this variable, but nothing worked. I'm not able to find anything about variables in the documentation either. I wish to know why does -f fail to follow the symlink path ONLY if passed via a variable? Is there a workaround? I'm not sure but, would it be recommended to bring this to notice here?
EDIT: Updating question after debugging. The original question has been preserved below:
I am aware that ssh-keygen has a flag -f to specify input_keyfile - With which, once can create a key with custom name at a custom location. However, this fails if the input_keyfile is a variable.
How do I provide the key path as a variable to ssh-keygen?
Following are oversimplified snippets from the bigger code:
This works perfectly:
export NewUser="Sam"
ssh-keygen -N "" -t rsa -b 8192 -C "Login Key of ${NewUser}." -f ~/.ssh/Official/demo
However, this fails with the following error Saving key "~/.ssh/Official/demo" failed: No such file or directory
export NewUser="Darsh"
export SSHKey_Path="~/.ssh/Official/demo"
ssh-keygen -N "" -t rsa -b 8192 -C "Login Key of ${NewUser}." -f ${SSHKey_Path}
I have tried wrapping ${SSHKey_Path} in several ways, but nothing worked:
", ', $(echo ${SSHKey_Path}), and many more.
The failure is not in the variable, but in the interpretation of ~.
Try
export SSHKey_Path=~/.ssh/Official/demo
or
export SSHKey_Path="$HOME/.ssh/Official/demo"

How do I force subprocess.call or os.system to run in bash, instead of dash?

Okay, so I've been struggling with this one for awhile. I'm trying to create a python3 script that automatically uploads a file to a server. In the commandline, the following command works like a charm:
sftp -i key.pem -P 3912 admin#myServerIP:home/files/ <<< $"put test.txt"
But, when I try to run that command in my python script (either through os.system('command') or subprocess.call('command')) I keep getting the following error:
/bin/sh: 1: Syntax error: redirection unexpected
After doing some research, I believe I found that I need to run the command in /bin/bash, instead of the default dash, but I've tried everything, and connot for the life of me figure out how to do that! I hope this is a simple, stupid fix, so I can be on my way. Thanks!
You can replace your command with this one:
/bin/bash -c 'sftp -i key.pem -P 3912 admin#myServerIP:home/files/ <<< $"put test.txt"'
which should work fine even in Dash. :-)
(Incidentally, I think you meant to write "put test.txt" instead of $"put test.txt". But that's neither here nor there.)
Edited to add: I should mention that your specific example is easy to rewrite in a Dash-compatible way:
echo "put test.txt" | sftp -i key.pem -P 3912 admin#myServerIP:home/files/
which may make more sense in this case. But you will very likely find the bash -c ... approach useful for other things in the future.

How to solve too many parameters error when using makecert?

I am following step 2 in this tutorial.
After entering this command,
makecert -r -pe -n "CN=PC-Name" -b 01/01/2000 -e 01/01/2036 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
I a getting ERROR: Too many parameters
How to solve this issue? Help please
The command looks like the following:
Makecert -r -pe -n CN="www.example.com" -b 05/10/2010 -e 12/22/2011 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
If you copy the sample command from the MSDN page above and run it via the command-line, you'll get error "Too many parameters". It turns out the dash used in the MSDN post above is actually character: \u2013 (DASH-EN) and not minus \u002D and it's the minus character that the tool is expecting.
So to make this work, simply replace the hyphen with the minus sign when keying in the command as defined above. In the above sample, I have replaced the incorrect character with the correct one so feel free to just copy and paste it.

Save file to specific folder with curl command

In a shell script, I want to download a file from some URL and save it to a specific folder. What is the specific CLI flag I should use to download files to a specific folder with the curl command, or how else do I get that result?
I don't think you can give a path to curl, but you can CD to the location, download and CD back.
cd target/path && { curl -O URL ; cd -; }
Or using subshell.
(cd target/path && curl -O URL)
Both ways will only download if path exists. -O keeps remote file name. After download it will return to original location.
If you need to set filename explicitly, you can use small -o option:
curl -o target/path/filename URL
The --output-dir option is available since curl 7.73.0:
curl --create-dirs -O --output-dir /tmp/receipes https://example.com/pancakes.jpg
curl doesn't have an option to that (without also specifying the filename), but wget does. The directory can be relative or absolute. Also, the directory will automatically be created if it doesn't exist.
wget -P relative/dir "$url"
wget -P /absolute/dir "$url"
it works for me:
curl http://centos.mirror.constant.com/8-stream/isos/aarch64/CentOS-Stream-8-aarch64-20210916-boot.iso --output ~/Downloads/centos.iso
where:
--output allows me to set up the path and the naming of the file and extension file that I want to place.
Use redirection:
This works to drop a curl downloaded file into a specified path:
curl https://download.test.com/test.zip > /tmp/test.zip
Obviously "test.zip" is whatever arbitrary name you want to label the redirected file- could be the same name or a different name.
I actually prefer #oderibas solution, but this will get you around the issue until your distro supports curl version 7.73.0 or later-
For powershell in Windows, you can add relative path + filename to --output flag:
curl -L http://github.com/GorvGoyl/Notion-Boost-browser-extension/archive/master.zip --output build_firefox/master-repo.zip
here build_firefox is relative folder.
Use wget
wget -P /your/absolut/path "https://jdbc.postgresql.org/download/postgresql-42.3.3.jar"
For Windows, in PowerShell, curl is an alias of the cmdlet Invoke-WebRequest and this syntax works:
curl "url" -OutFile file_name.ext
For instance:
curl "https://airflow.apache.org/docs/apache-airflow/2.2.5/docker-compose.yaml" -OutFile docker-compose.yaml
Source: https://krypted.com/windows-server/its-not-wget-or-curl-its-iwr-in-windows/
Here is an example using Batch to create a safe filename from a URL and save it to a folder named tmp/. I do think it's strange that this isn't an option on the Windows or Linux Curl versions.
#echo off
set url=%1%
for /r %%f in (%url%) do (
set url=%%~nxf.txt
curl --create-dirs -L -v -o tmp/%%~nxf.txt %url%
)
The above Batch file will take a single input, a URL, and create a filename from the url. If no filename is specified it will be saved as tmp/.txt. So it's not all done for you but it gets the job done in Windows.

Current directory appended to windows cmd passed in "parameter" causing invalid argument

I am trying to run a gimp batch command in windows cmd.
"C:\Program Files (x86)\GIMP-2.0\bin\gimp-console-2.6.exe" -i -b --verbose "(maketemplates \"C:\\autocovers\\sample\")" -b "(gimp-quit 0)"
I get the following:
GIMP-Error: Opening 'C:\Users\IOANNIS(maketemlpates "C:\autocovers\sample")' failed: Invalid argument
The argument does indeed seem invalid as it has the current directory appended to it! Any idea why this is happening?
I don't have GIMP installed on my Windows test boxes, so I can't test this, but I suspect that the --verbose option might be causing the issue.
The option -b expects an argument, but in your command-line you placed the option --verbose between -b and its argument, which would make the string --verbose the argument of -b. That leaves the intended argument "(maketemplates \"C:\\autocovers\\sample\")" as a non-option parameter. As documented, gimp-console considers all non-option parameters as file names.
Change your command-line from
"C:\Program Files (x86)\GIMP-2.0\bin\gimp-console-2.6.exe" -i -b --verbose "(maketemplates \"C:\\autocovers\\sample\")" -b "(gimp-quit 0)"</code>
to
"C:\Program Files (x86)\GIMP-2.0\bin\gimp-console-2.6.exe" --verbose -i -b "(maketemplates \"C:\\autocovers\\sample\")" -b "(gimp-quit 0)"</code>
and your problem should go away.

Resources