Over the past year or so I’ve been hosting (moderating?) a private slack channel for some of my friends from high school and previous jobs. What started as a small channel of about five people as since grown into a small community of around forty. While this isn’t an enormous number, it’s large enough that we’ve been eating through our storage space rather quickly. My first thought was to go to the Slack management console, erase a bunch of old files, and be about my day. Unfortunately, unless you’re on a paid tier you can’t manage files very well (you’d have to remove each one individually…and seeing as around 98% of our files were tiny memes that would take forever).
After some Googling around I found this awesome gist that did the bulk of the work for me. I just replaced the throwaway token with my own and saved the script. That should have been the end of it, but I kept getting a series of SSL errors on my Windows 10 machine that wouldn’t let me run the code.
After trying a variety of fixes and wasting about 45 minutes trying to get it working I learned that, apparently, there’s an old issue in Ruby where the net/http library by doesn’t check the validity of an SSL certificate during a TLS handshake. While the fix is very straightforward and easy, it took me a long time to find and figure out, so I decided I’d just write a super short guide for anyone else that had the same problem and hopefully make the solution easier to find.
- Download this gist somewhere easy to access—like your Desktop.
- Open the
slack_delete.rbfile and swap the blank token at the top of the file with the one you generate here.
- Download this cacert.pem file. (make sure it saves with the .pem extension)
- Start a Command Prompt with Ruby.
- Change to the directory where yo saved the script from Step 1:
cd FILE_PATH, where
FILE_PATHis the file’s location.
- Enter the following command:
$ set SSL_CERT_FILE=FILE_PATH\cacert.pemreplacing
FILE_PATHwith wherever you saved the cacert.pem file.
- Run the Ruby script with
Overall, the process is super simple and probably takes in the ballpark of five minutes total. One thing to note though is that as things stand the SSL fix is temporary. You’d have to manually set the
SSL_CERT_FILE property manually every time you get the error. I wanted to make the fix permanent so I went a few steps farther:
- Save the
cacert.pemfile somewhere safe—I went ahead and saved it in
- Open System in Control Panel.
- Click Advanced system settings on left (Windows 10).
- Click Environment Variables…
- Click New… (I made mine a system variable but I’m pretty sure it doesn’t matter if you make it a user one).
- Enter SSL_CERT_FILE under name and then, click Browse File… and select the certificate from Step 1.
- Click OK and you should be good to go.
Anyway, while none of the above is simple I couldn’t find it all in one place (the SSL fix on Windows and the Ruby script) so I figured I’d put them together and put it online. Hopefully, this saves someone time!