FAQ

MySQL乱码

表现现象

  • INSERT, UPDATE 时,中文成乱码(问号)
  • SELECT WHERE中包含中文时查不到结果

解决方法:http://note.youdao.com/noteshare?id=f2578f5b0c3209ebf44b7c42b43e2e10




SSL Handshake failed with OpenSSL error

如果遇到这类问题,例如:

(MySqlException) SSL Authentication Error
==>(AuthenticationException) Authentication failed, see inner exception.
==>(SslException) SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
==>(OpenSslCryptographicException) error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

或者

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
---> Interop+Crypto+OpenSslCryptographicException: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small
--- End of inner exception stack trace ---

这类问题和 .net 的基础镜像有关,可参考:https://github.com/dotnet/runtime/issues/30667

解决办法,修改 Dockerfile 增加以下内容:

RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /etc/ssl/openssl.cnf
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf
RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /usr/lib/ssl/openssl.cnf

例如:

FROM mcr.microsoft.com/dotnet/aspnet:5.0

ENV TZ=Asia/Shanghai
ENV ASPNETCORE_URLS=http://*:80
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN    sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf \
    && sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /etc/ssl/openssl.cnf \
    && sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf \
    && sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /usr/lib/ssl/openssl.cnf

WORKDIR /app
EXPOSE 80

ADD publish /app
ENTRYPOINT ["dotnet", "Nebula.Venus.dll"]




.netcore3不能连接SQLSERVER

异常提示:

Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught) 
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. 
---> Interop+OpenSsl+SslException: SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL. 
---> Interop+Crypto+OpenSslCryptographicException: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

参考链接:https://github.com/dotnet/SqlClient/issues/222

此问题的解决办法同上,问题的根源是一样的!