jdcloud-api / jdcloud-sdk-cpp-signer Goto Github PK
View Code? Open in Web Editor NEWC++ SDK签名库
License: Apache License 2.0
C++ SDK签名库
License: Apache License 2.0
$ make
Scanning dependencies of target jdcloudsigner
[ 5%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/JdcloudSigner.cpp.o
[ 11%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/HttpRequest.cpp.o
[ 17%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/HttpTypes.cpp.o
[ 23%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/Scheme.cpp.o
[ 29%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/URI.cpp.o
[ 35%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/DateTime.cpp.o
[ 41%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/StringUtils.cpp.o
[ 47%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/crypto/HashingUtils.cpp.o
[ 52%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/crypto/Sha256.cpp.o
/Users/lidaobing/workspace/jdcloud/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256.cpp:17:10: fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
^~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/CMakeFiles/jdcloudsigner.dir/util/crypto/Sha256.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/jdcloudsigner.dir/all] Error 2
make: *** [all] Error 2
header 不应当使用 using std::xxx
, 避免污染名字空间
$ make
Scanning dependencies of target jdcloudsigner
[ 5%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/JdcloudSigner.cpp.o
[ 11%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/HttpRequest.cpp.o
[ 16%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/HttpTypes.cpp.o
[ 22%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/Scheme.cpp.o
[ 27%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/http/URI.cpp.o
[ 33%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/DateTime.cpp.o
[ 38%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/StringUtils.cpp.o
[ 44%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/crypto/HashingUtils.cpp.o
[ 50%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/crypto/Sha256.cpp.o
[ 55%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/util/crypto/Sha256HMAC.cpp.o
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp: In constructor ‘HMACRAIIGuard::HMACRAIIGuard()’:
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:25:21: error: invalid use of incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
m_ctx = new HMAC_CTX;
^~~~~~~~
In file included from /usr/include/openssl/evp.h:14:0,
from /usr/include/openssl/hmac.h:15,
from /home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:17:
/usr/include/openssl/ossl_typ.h:102:16: note: forward declaration of ‘HMAC_CTX {aka struct hmac_ctx_st}’
typedef struct hmac_ctx_st HMAC_CTX;
^~~~~~~~~~~
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp: In destructor ‘HMACRAIIGuard::~HMACRAIIGuard()’:
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:31:16: warning: possible problem detected in invocation of delete operator: [-Wdelete-incomplete]
delete m_ctx;
^~~~~
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:31:16: warning: invalid use of incomplete type ‘struct hmac_ctx_st’
In file included from /usr/include/openssl/evp.h:14:0,
from /usr/include/openssl/hmac.h:15,
from /home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:17:
/usr/include/openssl/ossl_typ.h:102:16: note: forward declaration of ‘struct hmac_ctx_st’
typedef struct hmac_ctx_st HMAC_CTX;
^~~~~~~~~~~
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:31:16: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
delete m_ctx;
^~~~~
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp: In member function ‘HashResult Sha256HMAC::Calculate(const string&, const string&)’:
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:50:5: error: ‘HMAC_CTX_init’ was not declared in this scope
HMAC_CTX_init(m_ctx);
^~~~~~~~~~~~~
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:50:5: note: suggested alternative: ‘HMAC_CTX_new’
HMAC_CTX_init(m_ctx);
^~~~~~~~~~~~~
HMAC_CTX_new
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:56:5: error: ‘HMAC_CTX_cleanup’ was not declared in this scope
HMAC_CTX_cleanup(m_ctx);
^~~~~~~~~~~~~~~~
/home/lidaobing/workspace/jdcloud-sdk-cpp-signer/src/util/crypto/Sha256HMAC.cpp:56:5: note: suggested alternative: ‘HMAC_CTX_get_md’
HMAC_CTX_cleanup(m_ctx);
^~~~~~~~~~~~~~~~
HMAC_CTX_get_md
src/CMakeFiles/jdcloudsigner.dir/build.make:278: recipe for target 'src/CMakeFiles/jdcloudsigner.dir/util/crypto/Sha256HMAC.cpp.o' failed
make[2]: *** [src/CMakeFiles/jdcloudsigner.dir/util/crypto/Sha256HMAC.cpp.o] Error 1
CMakeFiles/Makefile2:163: recipe for target 'src/CMakeFiles/jdcloudsigner.dir/all' failed
make[1]: *** [src/CMakeFiles/jdcloudsigner.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
对于大于 4096 字节的场景,以及编译器没有把数组清零的场景,都会出错
root@jdsf-test:~/jdcloud-sdk-cpp-signer# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
root@jdsf-test:~/jdcloud-sdk-cpp-signer# cmake --version
cmake version 3.5.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
root@jdsf-test:~/jdcloud-sdk-cpp-signer# cmake .
CMake Error at src/CMakeLists.txt:87 (target_link_libraries):
Target "jdcloudsigner" of type OBJECT_LIBRARY may not be linked into
another target. One may link only to STATIC or SHARED libraries, or to
executables with the ENABLE_EXPORTS property set.
-- Configuring incomplete, errors occurred!
See also "/root/jdcloud-sdk-cpp-signer/CMakeFiles/CMakeOutput.log".
See also "/root/jdcloud-sdk-cpp-signer/CMakeFiles/CMakeError.log".
root@jdsf-test:~/jdcloud-sdk-cpp-signer# sudo dpkg -P libssl-dev
(Reading database ... 149624 files and directories currently installed.)
Removing libssl-dev:amd64 (1.0.2g-1ubuntu4.15) ...
root@jdsf-test:~/jdcloud-sdk-cpp-signer# sudo dpkg -P uuid-dev
(Reading database ... 149538 files and directories currently installed.)
Removing uuid-dev:amd64 (2.27.1-6ubuntu3.6) ...
root@jdsf-test:~/jdcloud-sdk-cpp-signer# cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /root/jdcloud-sdk-cpp-signer
root@jdsf-test:~/jdcloud-sdk-cpp-signer# make
Scanning dependencies of target jdcloudsigner
[ 4%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/JdcloudSigner.cpp.o
[ 8%] Building CXX object src/CMakeFiles/jdcloudsigner.dir/JdcloudSignerImpl.cpp.o
/root/jdcloud-sdk-cpp-signer/src/JdcloudSignerImpl.cpp:22:23: fatal error: uuid/uuid.h: No such file or directory
compilation terminated.
src/CMakeFiles/jdcloudsigner.dir/build.make:86: recipe for target 'src/CMakeFiles/jdcloudsigner.dir/JdcloudSignerImpl.cpp.o' failed
make[2]: *** [src/CMakeFiles/jdcloudsigner.dir/JdcloudSignerImpl.cpp.o] Error 1
CMakeFiles/Makefile2:146: recipe for target 'src/CMakeFiles/jdcloudsigner.dir/all' failed
make[1]: *** [src/CMakeFiles/jdcloudsigner.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
$ cat /usr/local/opt/glib/lib/pkgconfig/glib-2.0.pc
prefix=/usr/local/Cellar/glib/2.58.3
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
bindir=${exec_prefix}/bin
glib_genmarshal=${bindir}/glib-genmarshal
gobject_query=${bindir}/gobject-query
glib_mkenums=${bindir}/glib-mkenums
Name: GLib
Description: C Utility Library
Version: 2.58.3
Requires.private: libpcre
Libs: -L${libdir} -lglib-2.0 -L/usr/local/opt/gettext/lib -lintl -Wl,-framework -Wl,CoreFoundation
Libs.private: -L/usr/local/Cellar/pcre/8.42/lib -lpcre -lintl -Wl,-framework -Wl,CoreFoundation -liconv -Wl,-framework,Carbon -Wl,-framework,Foundation -Wl,-framework,AppKit
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I/usr/local/opt/gettext/include
$ pkg-config --cflags glib-2.0
-I/usr/local/Cellar/glib/2.58.3/include/glib-2.0 -I/usr/local/Cellar/glib/2.58.3/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.43/include
比如 ?a=1&a=2
与 ?a=2&a=1
的签名结果应该为一致的
?a=1&a=2
会被按照 ?a=1
签名
jdcloud-sdk-cpp-signer/src/JdcloudSigner.cpp
Line 115 in cc32f38
比如 "?a&b" 这种query,是否会变成 "a&b=" 而不是标准规定的 "a=&b="
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.