OpenSSL is written by monkeys
peereboom.us
peereboom.us
I agree with the opinion, though, because it took me a lot of time to figure this out.
This springs from a prescriptive viewpoint that presumes the reader will inevitably arrive at the same conclusions as the author about the right way to do things.
Since no one is always right, and API's are too often designed without considering what actual application usage would be like, this can be extremely frustrating.
The best API's that somehow hit the sweet spot of minimal, efficient, and obvious are always extremely impressive.
usage: x509 args
-in arg - input file - default stdin
-out arg - output file - default stdout
It does reading / writing via std{in,out} pipes - why not just spawn openssl with the right options and interact with it?Performance is a misdirected concern, here. Error-handling and reliability are better reasons to use the API over the tool.
The annoying answer is that it's "cleaner", the realistic answer is you don't have to account for as many potential problems you might encounter while executing applications on any given system. The sysadmin in me would use the tool but the programmer in me would use the API. (Oh, and depending on how heavily this application would get used, the API might be significantly faster and reduce load on the server...)
I used to work for a very large public facing certificate authority and there was a period in which one of the public CA systems used OpenSSL, so we had to be able to call several of the signing functions via a JNI extension. Why? Because OpenSSL has fairly remarkable support fir internal context objects that allow you to designate PKCS#11-interfaced hardware security modules for private key operations.
Yes, the levels of indirection are painful to read through and when you get down to the levels where you can actually do a signing operation you have multi-level points (something) of strange types, but it works almost magically when you need it to.
It's also the combined with the intersection of handling/reading certificates. The IO interface has to correctly handle PEM and DER information. Even if you can parse those structures all you're left with is ASN.1 annotated structures and ASN.1 is an exercise in pain.
So a library that can read a broad format of single-bit sensitive data, correctly decode and preserve the structure of ASN.1 entries, perform crypto operations, and then somehow make sense of it all across how many years is mostly likely going to be complicated as hell. Or at the very least, given my proficiency with C I think I would have a hard time coming up with a library that worked on as many platforms as transparently for as many years.
Building an entirely new replacement implementation will fight the battle of adoption. By wrapping initially an abstraction around the existing code, you can then go back and replace the original while at the same time, keeping everything relying on the original working. If you see Marco's initial work as a "shim" to enable replacement, it makes a lot more sense.
After creating roughly twelve hundred lines of C and hundred or so lines of command language to get OpenSSL working for network connections and to get a CA and signed certs a few weeks back, I can well appreciate the author's frustration with the OpenSSL library.
And at the same time this was being developed, one of the associated OS platforms went through an incompatible-API OpenSSL upgrade; you got to find and rebuild everything that was built against it, or you saw, um, cryptic failures.
Why did I have to reverse engineer it?
Because the documentation was both lacking and wrong.
If anyone is interested, an overview/interview with Marco Peereboom was recently published on the OpenBSD news site.
"In 2004, the head flying height was equivalent to a
Boeing 747 airliner flying at 0.05 cm above the ground
and travelling at 92 Km/h (7200 RPM drive)." That was
in 2004. What would that translate into these days?
The... same? At least, if you're using a 7200 RPM drive, but 10k and 15k drives existed in 2004 as well.Bit density has increased dramatically over the last six years, but rotational speed has remained constant, thanks to so some hard physical limits; and now that SSDs are no longer a howling black hole of suck on a dollar/GB basis, we won't see any more breakthroughs done with mechanical hard drives. Solid state drives are just better.
Oh wait, that's about all we ever hear. It makes for boring reading (and boring comments), so I'm flagging the article. When you write about how you've rewritten OpenSSL to be more flexible and featureful, I will enjoy reading about that. This? It just makes me mad.
(If you want to whine about a particular issue with a particular library, at least try to generalize it to something meaningful. The lesson here is "be careful writing a library that only one app uses and then calling it a library". A lot of C programs make this mistake; sure, they have a small app that calls libapp to do all the real work... but the functions that do the real work are things like read_config_file_and_then_handle_the_applications_foo_command, which is really unhelpful to everyone.)
Anyway... OpenBSD guy whining about code he didn't write? Big surprise. On HN, I want valuable articles that show me something cool or teach me how not to be uncool. This is just a rant that has no real value.
Sure, it's good to clean up old code to minimize the number of unanticipated failures. But this takes time and money; there aren't magic fairies that do things "because they should" or "because it's a critical piece of infrastructure". If it's boring and there is no money to be made, then it's not going to get done.
The author shows why; sometimes, it's just easier to hack around the problems than to fix them.
You are being unfair. I did a little Samba hacking in recent memory, and found it quite easy to understand and follow. (Granted, I didn't delve into the low-level implementation of Microsoft protocols.) I'm sure other well-written C programs exist.
Tcl/Tk is old code written in C. It's beautiful code; an absolute joy to work with. It was beautiful ten years ago, and it'll still be beautiful a hundred years from now when it is long forgotten by all but a handful of historians.
OpenSSL is a miserable codebase, and always has been.
Yes, bitching about other people's code is a popular hobby. Sometimes bitch because it's always easier to write something new than to understand the logic behind something old. And sometimes people bitch because the code is an absolute nightmare to work with.
OpenSSL is the latter.
OpenSSL is, by any sensible code quality metrics, a bloody mess. It is a miracle that this code has not caused more disastrous problems than it has. It is not only legitimate to criticize it: it is essential that we do and that we articulate what mistakes were made so that others may learn from it.
The documentation is a mess though.
Also, insulting the people working on it is no way to improve the situation.
Marco is a fantastic human being and absolutely hilarious. On top of all that, he's also an amazing programmer. Yes, I've met him in person, and we've traded emails and packages for years. In fact, there's a half a pallet of donated gear sitting behind me in need of being shipped out to him. --It should go without saying, but he's a friend and I have a strong bias.
Getting frustrated by widely deployed but poorly written software should be expected. Just voicing said frustrations solves nothing and wastes time, but voicing frustrations while providing an alternative is actually beneficial.
If you read the recent HN article: "How to keep someone with you forever" http://news.ycombinator.com/item?id=1677013
And ponder it a bit, you'll see how it applies to open source projects, and interactions on mailing lists, or as the case may be, a homepage article by an open source developer.
For me at least, the more fascinating question is why open source projects eventually degrade into "sick systems" of interaction? --I wish I had an answer, but the only speculation I have is it's the result of frustration.
I love OpenBSD though. Use it everyday. They don't pretend. What you see is what you get.
"I think the OpenBSD crowd is a bunch of masturbating monkeys"
http://news.cnet.com/Torvalds-attacks-IT-industry-security-c...
OpenSSL has always been bad, so it is not likely that it will improve any time soon unless someone who has a talent for API design decides to spend an immense amount of time sanitizing the library. This is a crypto library, so it is code that requires a lot of scrutiny. You can't simply make changes willy-nilly. Undoing the damage is no simple matter of programming.
I think it is important to point out badly designed APIs and make an example of them so people can learn why it is important to care about API design. It doesn't matter if it is open source or not. That is completely beside the point. Lots of open source code gets worked on by people who get paid for it or whose companies benefit from it directly or indirectly, so let's just be grown-ups and not derail the discussion.
Something being open source is not an excuse for doing a poor job. Bad code is bad code and OpenSSL does deserve harsh criticism for being unnecessarily hard to use.
I find the thought that you should not be able to criticize someone for designing bad APIs just because a project is open source offensive.