oesmith / puffing-billy

A rewriting web proxy for testing interactions between your browser and external sites. Works with ruby + rspec.
MIT License
656 stars 170 forks source link

Include pid in names of temporary files #290

Closed clayton-shopify closed 4 years ago

clayton-shopify commented 4 years ago

When running puffing-billy in a parallel test environment (for instance, in Rails 6), frequent crashes occur, with errors like the following:

123145443577856:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
123145443577856:error:140DC009:SSL routines:use_certificate_chain_file:PEM lib:ssl/ssl_rsa.c:622:
Assertion failed: (e > 0), function SslContext_t, file ssl.cpp, line 203.
123145562779648:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY
123145562779648:error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib:ssl/ssl_rsa.c:556:
Assertion failed: (e > 0), function SslContext_t, file ssl.cpp, line 196.

These errors occur because parallel puffing-billy processes will overwrite each other's certificate files. To solve the problem, I've prefixed the certificate filenames with the current process id.

ronwsmith commented 4 years ago

Thanks for the contribution. Do you know if these files get cleaned up at some point automatically? I'd want to avoid the directory continually growing and potentially causing issues.

clayton-shopify commented 4 years ago

Do you know if these files get cleaned up at some point automatically?

Yes, because they're stored in the operating system's temporary folder, which is periodically cleaned up:

https://github.com/oesmith/puffing-billy/blob/16a90c03b93b9fe6b80548390ad4901a9fd907e1/lib/billy/config.rb#L39

ronwsmith commented 4 years ago

Released in 2.4.0