How to decode CSR file using Perl? - perl

I'm currently working on a project for which I need to decode a Certificate Signing Request (CSR) -- basically mimic a site something like this. So, by pasting the CSR in a text area, the value will be passed in the backend and then decode the information and display it in the page.
The problem is that I need to run this using Perl, and I'm having a hard time looking for a good resource to start. I had already looked into OpenCA::OpenSSL but it seems like there's no available function that would fit when extracting the information in the details.

Have you tried searching the CPAN? Crypt::PKCS10 should be a good start

Related

Searching inside JSONs in Chrome devtools

Is there a possibility to searching inside all JSON objects from all available responses in the network tab? Currently it works, but very randomly and isn't much reliable. Sometimes and especially in a smaller responses it's ok but when you have more assets almost always looking for, e.g. specific params value ends unsuccessfully. Do you know any smart solution of that issue? I've checked and first question associated with it has already few years and Google devs still haven't responded.
Example: I have object ID in response body, but cannot find it by search CTRL+F
I think one way is to save all the response in a file (manually or automatically, if possibile by using a browser extension).
After you have stored all the responses in a file you can parse the file and find things inside the file by using a script or just regex.
You can save the answers (as HAR file) manually (I use firefox) by right clicking on a network response inside the developer console panel.
I found that is the same for chrome.
Look here:
https://developers.google.com/web/tools/chrome-devtools/network/reference
I didn't search if there is a way to automatically store all the responses received by a browser. I'm not sure, but I think it isn't possible :/

How to get serverside file uploading progress in Perfect

I'm trying to create a web page using Perfect(perfect.org), Where users will browse and upload files. Can anyone tell me how can I get the progress of file upload?
perfect.org-fileUploads
Refer above link and Do as-usual concept following in HTML-JS-PHP or HTML-JS-JSP or other programming
In other words
you can receive response status in percentage from server-side and display it to client or put loder while uploading the file
Thank you
Before an official solution released from PerfectlySoft Inc. for this feature request, you could try splitting the file into small pieces and upload them one by one, then merge them back to the server - since there is no such an industrial standard to apply, all other web servers either provide different solutions or simply stay away from it.

How can I return a text file and an error log from a webpage separately

I have a perl script which when run from the command line generates a text file of data with a specific format for use by another application. The script also prints informational warning messages on stderr. I'm writing a web front end for this. In an ideal world when the user clicks 'submit' on the associated form, a page would be displayed in the browser containing the informational messages, and simultaneously a pop-up would appear allowing the user to save the text file of data to disk. I would like this to work on browsers without javascript enabled, so I think exactly what I want is probably not possible.
Some sites I have seen deal with this kind of thing by displaying the page with the informational messages, and a link to the file to be downloaded. This would seem to mean having to store the files and sorting out some sort of security so that another user cannot download your file (not that this is a big deal for the application in question).
I'm wondering if there is a more elegant way of dealing with this? e.g Is it possible to use multipart messages to somehow achieve returning both pieces of information in one go? Is it possible to pop-up a second window with the informational messages without using javascript? Apologies if these seem like basic questions - my programming knowledge is in the domain of DNA sequence manipulation algorithms rather than web page generation..
If (and only if) the data is quick and easy to generate, do it once for error messages and a second time for download. The link or button of the error-message page would regenerate the results and prompt for download.
This is a bit of a hack since you need to consider what to do if the underlying data changes before the user hits the download link. Be careful to set the header correctly for file download vs normal webpage, eg,
if($submit) {
print header(-type=>'application/octet-stream',
-Content_disposition=>'attachment; filename=foobar.dat');
Gen_Results();
}
To be honest, I'd just use a little javascript anyway since it's a pretty safe assumption now a days. Otherwise, use a "noscript" tag for some alternative.

how do I set a Thunderbird signature to use a dynamic url's html?

I want to use a dynamic email signature in Thunderbird, that is context aware (depends on date, events in db, etc.)
If I have a PHP that can generate the signature html (i.e. http://www.site.com/email_sign.php)
how do I force Thunderbird to use it?
(the only options I see are using static html (whether inline, of from a local system file).
any ideas?
You can use the Signature Switch add-on and a batch file calling wget to achieve what you want. I wrote a simple executable to replace the bat file; you can read about it (and download it if you want to) from http://www.else.co.nz/portfolio/020-code/dynamic-email-signatures
I doubt you can do this simply. Thunderbird does allow scripting via the creation of plugins but I wouldn't personally know how do do it or how easy it might be.
Best answer I can think of would be to set a scheduled task / cron job to download the php to a local file then follow the instructions in the knowledge base, namely:
You can use Thunderbird to create signature files, or you can use your operating system tools to create them—for example, a plain text editor.
Thunderbird does not provide any
special place to store signature
files. You could create a Signatures
directory in your profile to store
them, making them easy to back up
along with the rest of your profile.
Or you could store them somewhere
else.
To use a signature file, specify it in
Account Settings as the signature for
an identity. Check the box "Attach the
signature from a file instead" and
specify the signature file.
This will work unless Thunderbird caches the HTML internally, however I see no indication in the FAQ that this is the case.
For years I updated the signature for my email client manually – until I got fed up… That’s why I wrote a PHP script to create a randomized signature block automatically from an RSS feed! Check it out: https://github.com/birdy1976/signature :-D

What do I need to build a file downloader in Perl?

I am working on a file downloader in Perl (UNIX/Mac OS X on terminal). I am actually searching for libraries that would work with handling checksum verification, progress bars and actually such things that the CPAN library itself uses. Which libraries and places to look can you recommend? Are there maybe some finished things like that around I don't know of?
More detailed:
downloading files with a progress bar
logging of all the action taken
file checksum verification
reading and parsing configuration files (example: YAML format)
sending of the results to a web service
CPAN is the main place to look for support modules. If you want to do it in Perl, it's quite likely someone's already done it.
For example, for your requirements:
MD5 (checksum) support: Digest::MD5
Progress bar: Term::ProgressBar
Logging: Log::Log4perl
Configuration files: YAML
Do not miss LWP. Specifically, LWP::Simple is likely most of what you need to get started. For checksumming, HTTP headers and the like, you probably want the full LWP user agent.
Look at CPAN::Checksums for the stuff that CPAN uses to create the CHECKSUMS file in each author's directory.
Sad to say, you really have to use POE currently.. Specifically you need to use POE::Component::Client::HTTP (for (Keep Alive)POE::Component::Server::HTTP::KeepAlive pooling), and probably a few more components. I just did this task I had to download 150k photos daily (in SQL) store by the sha1 of their url, resize them, hash them to their SHA1 of the image and hard link this to the sha1 of the url, and update a database to show the sha1 of the image and date downloaded. I did all of this with POE. And, other than a few hard to debug quirks that I'll probably never fix, and random POE core dumps, it works rather well.
We provide our third party affiliates with a much simpler image downloader that takes an image identified in a CSV through the VIN's row, downloads the image, and renames it to vin hyphen [1..n]. You can find it on github. It uses Parallel::ForkMangaer which is another solution but the nature of using it eliminates KA, and pooling that you can get rather easily with POE.
I'd highly suggest not rolling your own threaded solution, history tells us those are typically the worst.