0

First time setting up a a Pi and running into this... When I browse the wifi connections, I can see the wifi I want but it's greyed out. How do I connect to it? I found this but after following everything he did I actually ended up breaking my wifi connection status (side note, does anyone have the original wpa_supplicant.conf content? I think if I set it back to the default content it'll be fixed).

I think there's something wrong with my cert, I tried exporting my user cert from my (windows) work laptop (has connection to the wifi of interest) but I can't export the cert as .PEM. Only as .cer. Maybe this is the issue?

Looking for an pointers here, if someone wouldn't mind walking me through this process. This is so unbelievably frustrating.

  • Have you asked your network administrator? – Steve Robillard Jul 19 '17 at 0:21
  • @SteveRobillard Takes a really long time to get administrative stuff done here :/ – Capn Jack Jul 19 '17 at 13:21
1

openssl

openssl is a nice command line tool that's often used for converting between different certificate file formats. You'll probably be able to use that for the task.

Your .cer might already be in the PEM format, but if it's actually in DER format, you can try converting it with:

openssl x509 -in cert.crt -inform der -outform pem -out cert.pem

Default wpa_supplicant.conf

Firstly, the contents of the default wpa_supplicant.conf file:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Secondly, how I got it, because I'm a nerd and I enjoy these things.


Usually, I'd redownload the package and extract the original config file from that, but it doesn't appear to be available that way in this case:

pi@raspberry:~ $ mkdir wpasupplicant
pi@raspberry:~ $ cd wpasupplicant/
pi@raspberry:~/wpasupplicant $ apt-get download wpasupplicant
Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main wpasupplicant armhf 2.3-1+deb8u4 [778 kB]
Fetched 778 kB in 1s (488 kB/s)
pi@raspberry:~/wpasupplicant $ ar x wpasupplicant_2.3-1+deb8u4_armhf.deb
pi@raspberry:~/wpasupplicant $ tar -xf control.tar.gz
pi@raspberry:~/wpasupplicant $ tar -xf data.tar.xz
pi@raspberry:~/wpasupplicant $ tree -f | grep wpa_supplicant.conf
│   │       └── ./etc/dbus-1/system.d/wpa_supplicant.conf
│       │   │   │   └── ./usr/share/doc/wpasupplicant/examples/wpa_supplicant.conf.gz
│           │   └── ./usr/share/man/man5/wpa_supplicant.conf.5.gz

Since it's not in the package, the file must only be available in the default image. So we can download the current Raspbian image, mount it, and copy the file out.


First, we download the raspberry pi image and decompress it:

pi@raspberry:~/Downloads $ wget --quiet https://downloads.raspberrypi.org/raspbian_lite_latest
pi@raspberry:~/Downloads $ unzip raspbian_lite_latest
Archive:  raspbian_lite_latest
  inflating: 2017-07-05-raspbian-jessie-lite.img

Now we need to mount the image file in order to read the files inside of it. First, since the image file represents an entire sdcard, we need to find the offset of the second partition (which contains the root filesystem):

pi@raspberry:~/Downloads $ fdisk -l 2017-07-05-raspbian-jessie-lite.img

Disk 2017-07-05-raspbian-jessie-lite.img: 1.6 GiB, 1725629440 bytes, 3370370 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa8790229

Device                               Boot Start     End Sectors  Size Id Type
2017-07-05-raspbian-jessie-lite.img1       8192   93596   85405 41.7M  c W95 FAT32 (LBA)
2017-07-05-raspbian-jessie-lite.img2      94208 3370369 3276162  1.6G 83 Linux

We multiply the Sector Size by the Start Block to get the Offset...

pi@raspberry:~/Downloads $ echo $((512 * 94208))
48234496

...and use this information to mount the root filesystem, and copy the file:

pi@raspberry:~/Downloads $ sudo mkdir /mnt/2017-07-05-raspbian-jessie-lite
pi@raspberry:~/Downloads $ sudo mount -o loop,offset=48234496 2017-07-05-raspbian-jessie-lite.img /mnt/2017-07-05-raspbian-jessie-lite
pi@raspberry:~/Downloads $ sudo cp /mnt/2017-07-05-raspbian-jessie-lite/etc/wpa_supplicant/wpa_supplicant.conf ~/Downloads/wpa_supplicant.conf

Huzzah! We have our file now! Feel free to unmount the image file:

pi@raspberry:~/Downloads $ sudo umount /mnt/2017-07-05-raspbian-jessie-lite
  • That's really clever, just a question about the cert real quick though. Not sure if you're familiar with windows but I'm using mmc, then adding a cert snap-in as type "My user account". Then going to Personal > Certificates and exporting the cert viewed there as DER X.509(.CER). Is this correct? – Capn Jack Jul 19 '17 at 13:26
  • Yep, I think that's the right way to get the certificate from Windows. Since it says "DER", you should be able to copy it onto your raspberry pi, then use openssl to convert it to "PEM" so that the raspberry pi can use it. – Hydraxan14 Jul 19 '17 at 15:59
  • But is the right cert? I can select from "My user account", "Service account" and "Computer account". – Capn Jack Jul 19 '17 at 17:18
  • I think "My user account" is right. "Service account" would let you pick a user account that's used for running a service, and "Computer account" would let you pick the local computer, which I suppose is SYSTEM. – Hydraxan14 Jul 19 '17 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.