“Being a student is like someone behind bars; only those who burn the midnight oil will get the certificate of freedom.”
Related quotes

1990s, Long Walk to Freedom (1995)
Context: It was during those long and lonely years that my hunger for the freedom of my own people became a hunger for the freedom of all people, white and black. I knew as well as I knew anything that the oppressor must be liberated just as surely as the oppressed. A man who takes away another man's freedom is a prisoner of hatred, he is locked behind the bars of prejudice and narrow-mindedness. I am not truly free if I am taking away someone else's freedom, just as surely as I am not free when my freedom is taken from me. The oppressed and the oppressor alike are robbed of their humanity.
When I walked out of prison, that was my mission, to liberate the oppressed and the oppressor both. Some say that has now been achieved. But I know that that is not the case. The truth is that we are not yet free; we have merely achieved the freedom to be free, the right not to be oppressed. We have not taken the final step of our journey, but the first step on a longer and even more difficult road. For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others. The true test of our devotion to freedom is just beginning.

“Our wasted oil unprofitably burns,
Like hidden lamps in old sepulchral urns.”
Source: Conversation (1782), Line 357.

“Whence thy learning? Hath thy toil
O'er books consumed the midnight oil?”
Introduction, "The Shepherd and the Philosopher"; "Midnight oil" was a common phrase, used by Quarles, Shenstone, Cowper, Lloyd, and others.
Fables (1727)

“We spend our midday sweat, our midnight oil;
We tire the night in thought, the day in toil.”
Book II, no. 2.
Emblems (1635)

Don't Let It Bring You Down
Song lyrics, After the Gold Rush (1970)

“To burn oil!.. You can fuel with money as well.”