Sunday, October 2, 2022

Use curl to send 2 HTTP requests in one connection


$ curl -X POST http://myserver/myapp -d 'data-1' --next http://myserver/myapp -d 'data-2'

Friday, July 8, 2022

Java: no such provider: BC


Problem:

java.security.NoSuchProviderException: no such provider: BC


Solution:

1. Download Bouncy Castle JAR, e.g.: bcprov-jdk15on-157.jar

2. In the code, add:

  if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null)
  {
    Security.addProvider(new BouncyCastleProvider());
  }


Thursday, July 7, 2022

Linux: build OpenSSL 32bit on a 64bit box


$ setarch i386 ./config -m32 --prefix=... --openssldir=...


Wednesday, July 6, 2022

Tomcat: 403 access denied on manager


Problem:

403 Access Denied on Tomcat manager page: http://localhost/manager/html

 

Solution:

1. Go to /path/to/tomcat/webapp/manager/META-INF

2. Edit file context.xml, and remove/comment-out the following lines:

  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

3. Save context.xml

4. Restart Tomcat.

Tuesday, July 5, 2022

Linux: run valgrind on Apache httpd


Source code must be compiled with option -g

Command:

$ valgrind --leak-check=full --tool=memcheck --error-limit=no --log-file=val.log /usr/bin/httpd -f /etc/httpd.conf -DFOREGROUND


Monday, July 4, 2022

Bash: shell script to obtain the cipher list of a server


#!/bin/bash
 
SERVER=$1
 
if [[ "$SERVER" == "" ]]; then
  echo "Usage: $0 hostname:port"
  exit
fi
 
DELAY=2
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
 
for cipher in ${ciphers[@]}
do
  echo -n Testing $cipher ...
  result=$(echo -n | openssl s_client -cipher "$cipher" -connect $SERVER 2>&1)
 
  if [[ "$result" =~ "Session-ID:" ]]; then
    echo "YES"
  else
    if [[ "$result" =~ ":error:" ]]; then
      error=$(echo -n $result | cut -d':' -f6)
      echo "NO \($error\)"
    elif [[ "$result" =~ "errno=104" ]]; then
      echo "NO \(Connection reset by peer\)"
    else
      echo "Unknown response"
    fi
  fi
 
  sleep $DELAY
done
 

Sunday, July 3, 2022

Windows: Change SSL Cipher Suite


1. Right click on the Windows icon and select "Search".

2. Input "gpedit.msc". Right click on the gpedit.msc icon and select "Run as administrator".

3. The "Local Group Policy Editor" is loaded.

3.1. On its left panel, expand "Computer Configuration / Administrative Templates / Network", and then select "SSL Configuration Settings".

3.2. On the right panel, double click on "SSL Cipher Suite Order" to open "SSL Cipher Suite Order" dialogue.

3.3. At the top left side of the dialogue, select "Enabled" radio box.

3.4. At the lower left side of the dialogue, in the "Options" box, change the value of "SSL Cipher Suites".

3.5. Click the OK button to save the changes.

4. Restart the computer.


Saturday, July 2, 2022

Microsoft Outlook: Remove the primary account


  1. Close Outlook.
  2. Click the Windows icon and then Run menu. Run command: control mlcfg32.cpl.
  3. Click on Show Profiles.
  4. Click the Add button to create a new profile.
  5. Use Auto Account Setup to set up the new account.
  6. In the Mail window, make the new profile default by clicking on Always use this profile.
  7. Click Apply to save.
  8. Finally, just select your old profile and click Remove.

Saturday, May 14, 2022

Windows 11: Pin a "bat" shortcut to Start


1. Right click on the xx.bat file and copy.

2. Right click on the destination fold and select "Show more options" -> "Paste shortcut" to create a shortcut of the xx.bat file.

3. Right click on the newly created shortcut and select "Properties".

4. In the Properties dialog, change the Target field to:

    cmd /c "...../xx.bat"

    where the highlighted part is the original Target value. Click OK to save it.

5. Now, right click on the updated shortcut and you can see the "Pin to Start" item.


Sunday, January 23, 2022

Linux: edit PDF with LibreOffice Draw


On Linux, PDF files can be opened and edited by LibreOffice Draw.

However, depending on how the PDF is generated, the formatting of the file can be a mess when it is opened by LibreOffice Draw.

If that happens, we can use a PDF reader to open it first and print it into a SVG image file.

After that, use LibreOffice Draw to open the SVG file and edit it.

After the edit, LibreOffice Draw can export the modified image into a new PDF file.

 
Get This <