e2lc5's blog

e2lc5's blog

1.win键+R 进入cmd

输入regedit 回车

2.在注册表里找到如下项目并更改

安全中心
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SecurityHealthService
start值 2开启 4关闭
Windows Denfender
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender
DisableAntiSpyware值 0或者删除值开启 1关闭

目标:nginx配置多个https域名

查看nginx是否支持支持TLS协议的SNI扩展
1
2
3
4
5
6
7
 root@iZj6cgoyl5x6opizfwaukrZ:~# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.17.0
built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
built with OpenSSL 1.1.1 11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl-opt=enable-tlsext --with-pcre=./pcre-8.35
root@iZj6cgoyl5x6opizfwaukrZ:~#

 如果出现上面的TLS SNI support enabled,则略过第一步

更新nginx
1
2
3
4
5
6
[root]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root]# tar zxvf nginx-1.12.0.tar.gz
[root]# cd nginx-1.12.0
[root]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module \
--with-openssl=./openssl-1.0.2k \
--with-openssl-opt="enable-tlsext"

 其中openssl一般系统自带,可不添加
命令实行后建议,备份nginx.conf,进行重新安装,即make install

增加nginx的配置

直接增加server级的ssl配置即可

今天早上想给自己的服务器添加ssl证书,上传证书,配置证书后发现nginx没有配置ssl_module,只好自行添加了

1
2
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# nginx -s reload
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:99

首先,需要重新编译源码

1
2
3
4
5
6
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# cd 
...
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
...
/maxec/runtime/installer/nginx-1.14.2/
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# make

这一步千万不能 make install ;不然会把之前已经安装的nginx 覆盖掉
除非你已经备份了配置文件
如果中间发现缺少openssl库,可通过以下命令安装

1
2
sudo apt-get install openssl 
sudo apt-get install libssl-dev

现在,检查我们的安装是否生效

1
2
3
4
5
6
7
8
9
10
root@instance-0vy61lkh:/usr/local/nginx# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
root@instance-0vy61lkh:/usr/local/nginx/conf# /etc/init.d/nginx start
...
root@instance-0vy61lkh:/usr/local/nginx/conf# netstat -lnp|grep nginx
...

参考:
https://www.cnblogs.com/piscesLoveCc/p/6120875.html

问题

  • 今天打开自己的博客,发现二次打开时会被断开连接
    碰到这个问题第一时间觉的是nginx的ssl配置有问题
  • 随即开始对nginx的ssl进行调整,无论调整keepalive-timout
    ciphers,都没有效果,随即测试到底多久能再次打开
  • 经过测试,发现没有180s能够再次打开,然后查找有关180s的nginx配置
    发现有个proxy_timeout默认为180s,修改后无效,挠头了
  • 然后考虑是dns转换问题,使用地址访问后,每次都可以进入,然后用ping命令
    结果每次地址解析都正确,证明dns解析正常
  • 最后,发觉只能是ssl的问题,因为配置没问题,nginx没问题,最后屏蔽ssl配置后
    取消跳转,问题解决,看来便宜的ssl还是不行啊…

2019-10-31 20:11

做BOC支付时,需要对文件进行RSA签名
但是正确的数据,正确的bytes,正确的秘钥
却始终无法得到正确的结果
使用的是给出的RSA工具,其中java环境运行良好,代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* 私钥加密
*
* @param data
* @param PrivateKey
* @return
* @throws Exception
*/
public static byte[] encryptByPrivateKey(byte[] data, String PrivateKey) throws Exception {
byte[] keyBytes = Base64Utils.decode(PrivateKey);
PKCS8EncodedKeySpec pKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(keyBytes);
if (keyFactory == null) {
initKeyFactory(KEY_ALGORITHM);
}
Key privateK = keyFactory.generatePrivate(pKCS8EncodedKeySpec);
if (cipher == null) {
initCipher();
}
cipher.init(Cipher.ENCRYPT_MODE, privateK);
int inputLen = data.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offSet = 0;
byte[] cache;
int i = 0;
while (inputLen - offSet > 0) {
if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
cache = cipher.doFinal(data, offSet, MAX_ENCRYPT_BLOCK);
} else {
cache = cipher.doFinal(data, offSet, inputLen - offSet);
}
out.write(cache, 0, cache.length);
i++;
offSet = i * MAX_ENCRYPT_BLOCK;
}
byte[] encryptedData = out.toByteArray();
out.close();
return encryptedData;
}

其中cache = cipher.doFinal(data, offSet, inputLen - offSet);
返回数据错误
多方查证cipher的正确初始化方法为Cipher cipher = Cipher.getInstance(“RSA/ECB/PKCS1Padding”);

本文实例讲述了MySQL查询和修改auto_increment的方法。分享给大家供大家参考。具体如下:

查询表名为tableName的auto_increment值:

1
SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name="tableName";

修改表名为tableName的auto_increment值:

ALTER TABLE tableName auto_increment=number ;

希望本文所述对大家的MySQL程序设计有所帮助。
https://www.jb51.net/article/60948.htm

更新到3.5版本后,格式化布局文件代码,会自动给排序元素,导致界面布局错乱

解决办法:在布局文件界面按住ctrl+alt+shift+L快捷键,弹出下面的框,取消勾选Rearrange code即可

今天打开AS,突然之间好几个文件报错,打开一个java,发现个事是xml

解决方法:
删除/user/name/AS/system 这个文件夹

com.alibaba.fastjson.JSONException: syntax error, expect }, actual ,
这种是因为没有对报文中null进行泛型转换导致的

安装各种工具

Nginx

  • 参考

lrzsz

1
apt install lrzsz

Git

1
sudo apt install git

新增git用户

1
root@iZj6cgoyl5x6opizfwaukrZ:~# adduser git  

修改Git权限

1
2
3
visudo
# User privilege specification
root ALL=(ALL:ALL) ALL

在root ALL=(ALL:ALL) ALL这一行下面添加git ALL=(ALL:ALL) ALL

关闭git用户shell权限

执行:vim /etc/passwd
将最后一行的git:x:1001:1001:,,,:/home/git:/bin/bash修改为git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

部署

初始化仓库

1
2
3
4
cd /home/git            //切换到git用户目录  
mkdir blog.git //创建git仓库文件夹,以blog.git为例
cd blog.git //进入仓库目录
git init --bare //使用--

创建目录

1
2
cd /var/www/            //切换目录  
mkdir blog //创建网站目录,以blog为例

配置SSH

1
2
3
4
cd /home/git            //切换到git用户目录  
mkdir .ssh //创建.ssh目录
cd .ssh
vim authorized_keys

然后将本地的公钥复制到authorized_keys文件里(公钥即上文中本地执行cat ~/.ssh/id_rsa.pub查看的内容)

修改权限(重要)

修改 .ssh 目录的权限为 700

  修改 .ssh/authorized_keys 文件的权限为 600

1
2
3
4
5
sudo chmod 700 .ssh
cd .ssh
sudo chmod 600 authorized_keys
cd ..
sudo chown git:git -R .ssh

文件夹权限

1
2
3
4
5
6
7
8
9
10
11
ll /home/git/  
ll /var/www/
确保blog.git、.ssh、blog目录的用户组权限为git:git
若不是,执行下列命令后再查看:
sudo chown git:git -R /var/www/blog
sudo chown git:git -R /home/git/blog.git
直接启用git-shell似乎有问题
cp /usr/share/doc/git/contrib/git-shell-commands /home/git -R
$ chown git:developers /home/git/git-shell-commands/ -R
$ sudo chmod +x /home/git/git-shell-commands/help
$ sudo chmod +x /home/git/git-shell-commands/list

增加Hooks
配置Git Hooks
创建post-receive文件
git用户下执行:
cd /home/git/blog.git/hooks //切换到hooks目录下
vim post-receive //创建文件
复制下面的内容到post-receive文件中:

1
2
3
4
5
6
7
8
#!/bin/bash -l  
GIT_REPO=/home/git/blog.git
TMP_GIT_CLONE=/tmp/blog
PUBLIC_WWW=/var/www/blog
rm -rf ${TMP_GIT_CLONE}
git clone $GIT_REPO $TMP_GIT_CLONE
rm -rf ${PUBLIC_WWW}/*
cp -rf ${TMP_GIT_CLONE}/* ${PUBLIC_WWW}

保存退出后,执行:sudo chmod +x post-receive赋予可执行权限。

测试Git连接
3.Git服务器打开RSA认证
/etc/ssh/sshd_config中将RSA认证打开:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

1
2
在本地打开Git Bash:  
ssh git@VPS的ip
0%