Skip to content

Instantly share code, notes, and snippets.

@junxy
junxy / Howto convert a PFX to a seperate .key & .crt file.md
Created March 23, 2016 05:37 — forked from TemporaryJam/Howto convert a PFX to a seperate .key & .crt file
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX

source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/

openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]

What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.

Now let’s extract the certificate:

openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]

@junxy
junxy / README.md
Created January 7, 2024 05:46 — forked from cld4h/README.md
Bypass the GFW; clash fake-ip and tproxy; iptables and transparent proxy on Linux; 在Linux上通过 iptables 以及 clash 配置透明代理用于本机及局域网翻墙网关; Linux 翻墙路由器配置

This article show you the ultimate way to set up a transparent proxy on Linux using clash and iptables to bypass the GFW in China.

We use:

You can go to github gist to download all files mentioned in this article.

@junxy
junxy / AnnotationExtUtils.java
Created September 8, 2022 09:41
find annotation recursively
package com.demo.util;
import lombok.NonNull;
import lombok.experimental.UtilityClass;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.Nullable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
if type pactl > /dev/null 2>&1 || type xvinfo > /dev/null 2>&1; then
# detect WSL host
if type systemd-detect-virt > /dev/null 2>&1 && test "$(systemd-detect-virt -c)" != wsl -a -e /etc/resolv.conf; then
WSL_HOST=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null)
fi
WSL_HOST=${WSL_HOST:-localhost}
# set DISPLAY if there is an X11 server running
@junxy
junxy / BeanUtils2.java
Last active December 28, 2020 06:22
Bean属性复制 忽略空值/空白字符
package test;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.beans.PropertyDescriptor;
import java.util.HashSet;
import java.util.Set;
public static string GenerateSaltedSHA1(string plainTextString)
{
HashAlgorithm algorithm = new SHA1Managed();
var saltBytes = GenerateSalt(4);
var plainTextBytes = Encoding.ASCII.GetBytes(plainTextString);
var plainTextWithSaltBytes = AppendByteArray(plainTextBytes, saltBytes);
var saltedSHA1Bytes = algorithm.ComputeHash(plainTextWithSaltBytes);
var saltedSHA1WithAppendedSaltBytes = AppendByteArray(saltedSHA1Bytes, saltBytes);
@junxy
junxy / Test4.java
Last active December 9, 2020 03:48
Java queryString to obj Example sample 两行代码(使用已有工具库)实现QueryString转对象,拒绝硬编码
package test;
import lombok.Data;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.junit.Test;
@junxy
junxy / Logstash-log4net-README.md
Last active July 14, 2020 07:15 — forked from dterziev/logstash.conf
Logstash 2.1.x config for log4net logs.
<!- .... ->
<log4net>    
    <appender name="RollingLogFileAppenderLogstash" type="log4net.Appender.RollingFileAppender">
      <encoding value="utf-8" />
      <!--该目录必需有 IIS用户 写权限-->
      <file value="X:/var/log/[app_name]/logfile.log" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
@junxy
junxy / jdk1.8.0_151-install.txt
Last active April 28, 2020 13:19
Oracle JAVA -JDK Installation & Configuration Script 1.8.0_151
#//INSTRUCTIONS FOR DOWNLOADING AND INSTALLING JAVA WITHIN LINUX SYSTEMS AND UPDATING ALTERNATIVES FILES
#// rpm Installation Oracle JDK 1.8.0_151
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"  http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm
#// installation command
#// -i = install
#// -n = non-interactive
#// -v = verbose
#// -h = The hash table is a feature of bash that prevents it from having to search $PATH every time you type a command by caching the results in memory.
@junxy
junxy / nginx_proxy_updates.jenkins-ci.org.conf
Last active April 22, 2020 12:28
nginx 反向代理 Jenkins 插件安装源,国内源 http://mirrors.tuna.tsinghua.edu.cn/jenkins/
server {
listen 80;
server_name updates.jenkins-ci.org;
server_name mirrors.jenkins-ci.org;
# https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
location /download/ {
proxy_redirect off;
proxy_pass http://mirrors.tuna.tsinghua.edu.cn/jenkins/;
proxy_connect_timeout 60s;