18

I'm trying to sign some kernel modules (for virtualbox) as explained here.

As explained there, I create the new keys:

openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/"

I sign all the modules:

sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxnetadp)
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxnetflt)
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxpci)

But when it comes to importing the keys, that fails

$ sudo mokutil --import MOK.der
input password: 
input password again: 
Failed to enroll new keys

What could be causing this?

EDIT: Actually, I just noticed that I really can't do much with mokutil. For example:

$ sudo mokutil --reset
input password: 
input password again: 
Failed to unset MokNew
Failed to write MokAuth
Failed to unset MokNew
Failed to issue a reset request

I think that the only commands that don't fail somehow are --sb-state which correctly states that SecureBoot is enabled, and --list-enrolled which lists enrolled keys. Everything else errs in some way.

Community
  • 1
  • 1

5 Answers5

12

If you are on Ubuntu you don't need to set a root password. Not sure about other distros, but this should work with any distro that uses sudo.

sudo su
mokutil --import MOK.der

It should work without error now. Then to get back to a normal prompt just type.

exit

or simple

reboot

You now need to go through the UEFI prompt to add your key. Whatever you named it should show up, at least it did for me on my system.

Now you should be able to use your software.

Goddard
  • 2,863
  • 31
  • 37
3

Had the same issue. Did a bit digging around with mokutil --help and was able to get things to work like this:

mokutil --set-verbosity true #optional
mokutil --password #enter password when prompted
mokutil --import MOK.der #enter same password

Posting it here in the hope that it helps someone. I have no clue why it works like this. All I'm trying to do is get VMware Workstation to work on Ubuntu with Secure Boot turned on :)

PS: Ubuntu 20.04.1 Desktop

Bhavin
  • 61
  • 1
  • 4
2

I had the same problem and found that UEFI boot had to be enabled while using modutil. (I had it disabled to use vmware workstation.)

Hope that helps!

sebkraemer
  • 435
  • 3
  • 12
  • Hey, this was a while ago. I never solved it, I just disabled some sort of check and now I use unsafe boot. I don't wanna break my current installation by changing things now, but next time I reinstall my OS maybe I'll come back and try your suggestion. Thanks. –  Feb 02 '17 at 19:39
2

I was able to solve this:

  1. set a root passord (as I am using Ubuntu and it is not set by default)
  2. doing it as root and with option --root-pw
Pang
  • 9,564
  • 146
  • 81
  • 122
0

Running the command as sudo solved the issue for me

Tarik Waleed
  • 97
  • 1
  • 8